qmathe / DropDownMenuKit

UIKit drop down menu, simple yet flexible and written in Swift
Other
303 stars 38 forks source link

hide when choose a cell #6

Closed FredvanRijswijk closed 7 years ago

FredvanRijswijk commented 7 years ago

Hi,

Where it's best to close the DropDownMenu when you have selected a item Cell? Now you have to select the titleView or the Menubackground

qmathe commented 7 years ago

You can simply close the menu by calling DropDownTitleView.toggleMenu() when the checked item changes and the menu is opened.

In the project example, this could be done by calling toggleMenu() in the choose action of the ViewController:

    @IBAction func choose(_ sender: AnyObject) {
        titleView.title = (sender as! DropDownMenuCell).textLabel!.text
            if titleView.isUp {
                    titleView.toggleMenu()
            }
    }
FredvanRijswijk commented 7 years ago

thnx! I was forgotten if titleView.isUp so it was crashing before, no it's working perfect

qmathe commented 7 years ago

I could improve the example to avoid the check titleView.isUp.

In fact, it's surely better to avoid calling selectMenuCell(_:) in prepareNavigationBarMenu() and simply do secondCell.accessoryType = .checkmark.