John-Lluch / SWRevealViewController

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

disable seguesetcontroller in code #682

Open moostafaa opened 7 years ago

moostafaa commented 7 years ago

I have two segue in my code one for sw_rear and one for sw_right, i need to disable one of them in particular situation, Is it possible? if yes how can should I do it? at this time I disabled pan gesture recognizer so my users have to open reveal view by selecting menu buttons, using this technique I am able to hide or show right or left menu on the fly. but I need to enable pan gesture in my app.

iDevelopper commented 7 years ago

Use the delegate method:

    func revealControllerPanGestureShouldBegin(_ revealController: SWRevealViewController!) -> Bool {
        return true // or false
    }
moostafaa commented 7 years ago

thanks for response but how can I understand which segue is called sw_rear or sw_right? I implemented this delegate

iDevelopper commented 7 years ago
    func revealControllerPanGestureShouldBegin(_ revealController: SWRevealViewController!) -> Bool {
        let velocity = revealController.panGestureRecognizer().velocity(in: revealController.view).x
        if velocity < 0 {
            print("Direction: Left (Should open right view)")
        }
        else {
            print("Direction: Right (Should open rear view)")
        }
    }
moostafaa commented 7 years ago

I solved this by getting gesture direction, thanks for you help.