因此,我在为iOS 7构建的应用程序中有一个导航控制器。titleView是可见的,后退按钮和导航栏也是可见的。由于某些原因,交互式弹出手势(从左侧滑动)不起作用。什么都没发生。当我记录这个手势时,它不是nil。要启用此功能,我需要执行什么特殊操作吗?是什么原因导致它无法工作?
发布于 2013-09-23 03:37:28
嗯,看起来我只需要设置手势委托并实现以下内容:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return YES;
}发布于 2015-07-20 23:00:36
看看这个response和评论。您所要做的就是将导航控制器的交互式弹出手势识别器的委托设置为nil
self.navigationController.interactivePopGestureRecognizer.delegate = nil;将其设置为强制转换为id<UIGestureRecognizerDelegate>也是有效的,因为协议中的所有方法都是可选的,但我认为在这种情况下,将委托设置为nil更合适。
发布于 2019-08-27 17:21:14
我的答案是基于Eneko的答案,但只使用了UINavigationController上的一个扩展,并且适用于Swift 5:
extension UINavigationController: UIGestureRecognizerDelegate {
override open func viewDidLoad() {
super.viewDidLoad()
interactivePopGestureRecognizer?.delegate = self
}
public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
return viewControllers.count > 1
}
}https://stackoverflow.com/questions/18946302
复制相似问题