I have an app where I need to disable the interactivePopGestureRecognizer
so my custom slide menu does not show up. I think I might have pretty much tried everything that was mentioned in SO with no luck. My .h
includes UIGestureRecognizerDelegate
and in my .m
file, I have the following code which was mentioned in quite a few questions. But it does not seem to work in iOS 8 (I am running 8.3)
. One other thing I have noticed is that the delegate method gestureRecognizerShouldBegin
gets called but has no effect.
Does anybody know or have found a solution for this? As always, thanks for your help in advance. FYI, this code works fine in iOS7.
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
return NO;
}
I found that setting self.navigationController.interactivePopGestureRecognizer.enabled = NO
works on iOS 8.3, but only if performed in viewDidLayoutSubviews
.
Re-enable by setting the property to YES
in viewWillDisappear
.
i hope you have used navigation controller as your root view controller in app delegate file.
in that case put this code in applicationdidfinishlaunching
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.