質問

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?

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top