I am using SWRevealViewController in order to implement a side nav menu in my app. I would like to make it so that the front view cannot be interacted with when
I used the tapGestureRecognizer but there are still some problems. I tried this and worked great!
Define class:
@interface IgnoreView : UIView
@property (nonatomic, assign) BOOL shouldAllTouchesBeForMe;
@end
Implement:
@implementation IgnoreView
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
if( self.shouldAllTouchesBeForMe ){
return self;
}
return [super hitTest:point withEvent:event];
}
@end
Then make your View class in Interface Builder of class IgnoreView
In your ViewController, then, do:
in - viewDidLoad
self.revealViewController.delegate = self;
[self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
the implement in your viewcontroller also:
- (void)revealController:(SWRevealViewController *)revealController didMoveToPosition:(FrontViewPosition)position
{
IgnoreView *i = (id)self.view;
i.shouldAllTouchesBeForMe = position == FrontViewPositionRight;
}
And you're all set!