Question

I am using SWRevealController class to add a sidebar. This adds a gesture recogniser for a swipe.

I have a table with a few choices and initially the swipe works fine. However, if I select a choice, go to the new page and then come back via the nav, the swipe STOPS working (however the button for the sidebar still works).

This is the code for the swipe added to viewDidLoad

[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];

What do I need to do to fix it?

Was it helpful?

Solution

Call [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer]; in viewWillAppear instead of viewDidLoad so that it is replaced following each transition. A gesture can only be attached to one view at a time so when you attach it to a different view it gets removed from the first.

Alternatively, consider adding the gesture to a more root view (like the window / navigation bar) depending on what interaction you want to enable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top