BTNavigationDropdownMenu icon indicating copy to clipboard operation
BTNavigationDropdownMenu copied to clipboard

Only opening dropdown menu when tapping on center

Open aivantg opened this issue 9 years ago • 4 comments

Dropdown view won't open when I press on the drop down button. It will only work when I tap the center of the text, which isn't where a user would instinctively tap.

aivantg avatar Dec 02 '15 04:12 aivantg

I don't notice this behavior, tapping on the arrow works as expected.

TheBogueRat avatar Dec 08 '15 13:12 TheBogueRat

Problem in this code:

// Get titleSize
let titleSize = (title as NSString).sizeWithAttributes([NSFontAttributeName:self.configuration.cellTextLabelFont])

// Set frame
let frame = CGRectMake(0, 0, titleSize.width + (self.configuration.arrowPadding + self.configuration.arrowImage.size.width)*2, self.navigationController!.navigationBar.frame.height)

For example, If title is only 5 characters long and second item title is 20 characters long, then taps near bounds of second item will not work. I think you should recalculate frame after changing an item.

respan avatar Apr 06 '16 01:04 respan

The menu Button frame should dynamically update when another menu item is selected. This might be achieved with a delegate method.

maybe a temporary workaround is to set the frame according to the longest title's size, not to the initial nav bar title.

in the initializer I changed the code as shown below. However, now it is possible to tap outside of the shortest title and the menu still opens.... But still better than not being able to tap the arrow beside the longest title.

// Get titleSize // get longest title

    var titleLength = CGFloat(0)
    var longestTitle = title
    
    for item in items {
        
        let titleWidth = (item.title as NSString).size(attributes: [NSFontAttributeName:self.configuration.navigationBarTitleFont]).width
        
        if titleWidth > titleLength {
            titleLength = titleWidth
            longestTitle = item.title
            print("longest title is  \(item.title)")
        }
        
    }
    
   let titleSize = (longestTitle as NSString).size(attributes[NSFontAttributeName:self.configuration.navigationBarTitleFont])
 

here is the complete code: https://github.com/DominikButz/BTNavigationDropdownMenu/tree/ItemImage

DominikButz avatar Feb 07 '17 07:02 DominikButz

This problem still exists Any fix ?

UtkuDalmaz avatar Dec 19 '18 13:12 UtkuDalmaz