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

Swipe to show rearViewController not working. #577

Closed wvdk closed 3 years ago

wvdk commented 8 years ago

It works if I add [_frontViewController.view addGestureRecognizer:_panGestureRecognizer]; to setFrontViewPosition:animated:, but I don't want to modify the source because I'm using Cocoapods.

What am I missing? How do I add the correct panGestureRecognizer from inside of the frontVC? If anyone could point me in the right direction, that's be great.

iDevelopper commented 8 years ago

Just do that:

[self.revealViewController panGestureRecognizer];
larsblumberg commented 8 years ago

@wvdk I'm having the same issue – swiping doesn't reveal the rear view controller.

As suggested by http://www.appcoda.com/sidebar-menu-swift/ I added this snippet to the front's view controller viewDidLoad method:

if revealViewController() != nil {
    menuButton.target = self.revealViewController()
    menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
    view.addGestureRecognizer(revealViewController().panGestureRecognizer())
}

This doesn't make swiping work. Tapping the menu button however reveals the rear view controller.

Edit: Swiping actually does work but only if I don't start swiping on the navigation bar. I expected to unreveal the rear view controller this way, too. Any ideas?

larsblumberg commented 8 years ago

@iDevelopper Can you please provide a more detailed description how your suggestion is supposed to be applied?

iDevelopper commented 8 years ago

Here is a sample I wrote for another thread (I use a subclass of SW but it is not mandatory). If you not, just call the tapGesture & panGesture in your first frontViewController:

MapSample.zip

Hope this help!

iDevelopper commented 8 years ago

Another sample write with Objective-c:

SWSample.zip

larsblumberg commented 8 years ago

Thank you very much, I will have a look into it how you solved it.