objective-c – iOS 8 UINavigationController禁用后退按钮

前端之家收集整理的这篇文章主要介绍了objective-c – iOS 8 UINavigationController禁用后退按钮前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的导航控制器中,我需要暂时禁用后退按钮.我知道它可以隐藏使用以下或类似的东西:

[self.navigationController.navigationItem setHidesBackButton:YES animated:YES];

但是这不是我需要的,而是要让后退按钮变灰,并且不响应用户触摸事件.他们是不是替换默认的返回按钮来实现的?

提前致谢!

解决方法

要禁用后退按钮,这些命令将使您执行所需的操作:

启用:

self.navigationController.navigationBar.userInteractionEnabled = YES;
self.navigationController.navigationBar.tintColor = [UIColor blueColor];

禁用:

self.navigationController.navigationBar.userInteractionEnabled = NO;
self.navigationController.navigationBar.tintColor = [UIColor lightGrayColor];

更新:

从iOS 7开始,您也可以在UINavigationBar上禁用滑动.

// You wrap it an 'if' statement so it doesn't crash
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
// disable the interactivePopGestureRecognizer
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
原文链接:https://www.f2er.com/c/115822.html

猜你在找的C&C++相关文章