I've implemented SWRevealViewController
according to the tutorials I've seen for a hamburger slide menu. Things are working great, except if I use the slide menu on a later page in the app, and then collapse it, and then go to an earlier page and try to use it, it will open, but no gestures will collapse it unless I navigate back to the page that last opened the menu. Then I can close it from there.
The code I'm using in the viewDidLoad
of each ViewController
is
let menuButton = self.navigationItem.rightBarButtonItem
if self.revealViewController() != nil {
menuButton?.target = self.revealViewController()
menuButton?.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
self.view.addGestureRecognizer(self.revealViewController().tapGestureRecognizer())
}
Any ideas what's causing this/how to fix it?
Remove the code from ViewDidLoad
and use it in ViewDidAppear
.
ViewDidLoad
runs only once, when UIViewController
class is loading.
ViewDidAppear
runs every time the UIViewController
appears on screen.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.