Zy Mazza Zy Mazza - 1 year ago 142
Swift Question

SWRevealViewController Swipe/Tap gesture not working properly

I've implemented

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
of each

let menuButton = self.navigationItem.rightBarButtonItem
if self.revealViewController() != nil {
menuButton?.target = self.revealViewController()
menuButton?.action = "revealToggle:"


Any ideas what's causing this/how to fix it?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download