iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Dismiss keyboard when menu button pressed #76

Closed justdan0227 closed 4 years ago

justdan0227 commented 4 years ago

Where do we put logic to dismiss the keyboard if the menu option is pressed or it is pulled out from the side?

iDevelopper commented 4 years ago

In a delegate function, example:

    // MARK: - PBRevealViewController Delegate

    func revealController(_ revealController: PBRevealViewController, willShowLeft viewController: UIViewController) {
        revealController.mainViewController?.view.alpha = 0.9
        revealController.mainViewController?.view.isUserInteractionEnabled = false
        if let nc = revealController.mainViewController as? UINavigationController, let mainVC = nc.topViewController as? MainViewController {
            mainVC.textField.resignFirstResponder()
        }
    }
justdan0227 commented 4 years ago

Thanks