作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用以下代码集禁用我的 View Controller 的后退手势。
在 FirstViewController.m
,我正在设置 interactivePopGestureRecognizer
的代表
- (void) viewWillLoad {
// Other stuff..
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
<UIGestureRecognizerDelegate>
方法并返回
NO
.
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
return NO;
}
- (void)dealloc {
self.navigationController.delegate = nil;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
FirstViewController
.但是当我推
SecondViewController
对此,手势也不起作用。如何仅在 FirstViewController 中禁用手势?
FirstViewController
前往
RootViewController
然后尝试推送
FirstViewController
再次,我得到对象释放错误:
[FirstViewController gestureRecognizer:shouldReceiveTouch:]: message sent to deallocated instance 0x14ed0280
最佳答案
在您的 FirstViewController 中尝试以下未经测试的代码:
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
-(void) viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
关于ios7 - 如何仅在一个 View 中禁用 iOS 7 中的后退手势,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19108601/
我是一名优秀的程序员,十分优秀!