Dan*_*Dan 18 uinavigationbar uinavigationcontroller uigesturerecognizer ios7
我有一个嵌套在一个视图控制器UINavigationController
.
我已经实现了iOS 7的interactivePopGestureRecognizer,使用户可以手势将VC从堆栈中弹出.
在VC中我有一个滚动视图,当用户不在滚动视图的顶部时,我隐藏了所有的chrome(导航栏和状态栏)以将焦点放在内容上.
但是,如果隐藏了导航栏,则interactivePopGestureRecognizer将无法正常工作.
我已经尝试在它消失后启用它并验证它不是零,但它仍然不起作用.
有什么我想念的吗?
sim*_*dox 37
将您的UIViewController子类设置为gestureRecognizer的委托:
self.navigationController.interactivePopGestureRecognizer.delegate = self;
Run Code Online (Sandbox Code Playgroud)
而已!
Nag*_*raj 16
简单解决方案
只需通过导航控制器设置导航栏的隐藏属性即可
只需使用这两行
self.navigationController.navigationBarHidden = NO;
self.navigationController.navigationBar.hidden = YES;
Run Code Online (Sandbox Code Playgroud)
小智 7
我用过这个.
self.navigationController.interactivePopGestureRecognizer.delegate = self;
也在我的UINavigationController类中,在转换期间禁用interactivePopGestureRecognizer.
- (void)pushViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.interactivePopGestureRecognizer.enabled = NO;
}
[super pushViewController:viewController animated:animated];
}
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
// disable interactivePopGestureRecognizer in the rootViewController of navigationController
if ([[navigationController.viewControllers firstObject] isEqual:viewController]) {
navigationController.interactivePopGestureRecognizer.enabled = NO;
} else {
// enable interactivePopGestureRecognizer
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
}
Run Code Online (Sandbox Code Playgroud)
在rootViewController中禁用interactivePopGestureRecognizer的原因是:当从rootViewController中的边缘滑动然后在下一个viewController中点击某些内容时,UI将不会接受任何触摸.按下主页按钮将应用程序置于后台,然后点击它进入前景...
归档时间: |
|
查看次数: |
12635 次 |
最近记录: |