John-Lluch / SWRevealViewController

A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right !
Other
4.52k stars 987 forks source link

How can I make it so that the user can only swipe a view back to the menu (video attached)? #413

Open ghost opened 9 years ago

ghost commented 9 years ago

Made a short 30 sec video about what i mean: https://www.youtube.com/watch?v=Hf2gt5FWl1E&feature=youtu.be

Please help! Thanks :)

unes-es commented 9 years ago
override func viewDidLoad() {
    super.viewDidLoad()
    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
ghost commented 9 years ago

Thanks. Btw. is there i was i can both make the navigation bar and and view swipable at the same time? It seems like as soon as i implement code for swiping the navigationbar, the code for swiping the view stops working.

// For nav bar swiping: navigationController?.navigationBar.addGestureRecognizer(revealViewController().panGestureRecognizer())

John-Lluch commented 9 years ago

This has been answered several times. A gesture recognized can only be attached to a single view. Also, If you just call revealViewController.panGestureRecognizer the class will automatically attach it to the internal view that supports your front controller to achieve what you want.

ghost commented 9 years ago

I'm not sure I understand the solution? Is there a thread with the solution? When i add revealViewController.panGestureRecognizer, I still can't swipe both the view and the navbar. I use this code to enable the navbar swiping, but as mentioned, they the view and navbar can't work at the same time: navigationController?.navigationBar.addGestureRecognizer(revealViewController().panGestureRecognizer())