iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

How to prevent main view controller from receiving touch events? #3

Closed schmidt9 closed 8 years ago

schmidt9 commented 8 years ago

Hello, If I tap outside of left view going to hide it and the finger lands on a button in main VC, the button triggers unwanted tap event. How to disable touch events in main VC until left view goes away?

iDevelopper commented 8 years ago

I updated PBRevealViewController to allow tap gesture to be recognize on the main view when userInteractionEnabled is false (v. 1.0.5).

Then use the delegate methods:

    func revealController(revealController: PBRevealViewController!, didShowLeftViewController controller: UIViewController!) {
        revealController.mainViewController.view.userInteractionEnabled = false
    }

    func revealController(revealController: PBRevealViewController!, didHideLeftViewController controller: UIViewController!) {
        revealController.mainViewController.view.userInteractionEnabled = true
    }

    func revealController(revealController: PBRevealViewController!, didShowRightViewController controller: UIViewController!) {
        revealController.mainViewController.view.userInteractionEnabled = false
    }

    func revealController(revealController: PBRevealViewController!, didHideRightViewController controller: UIViewController!) {
        revealController.mainViewController.view.userInteractionEnabled = true
    }
schmidt9 commented 8 years ago

Thanks for quick fix!