在我的UINavigationController中,我添加了自定义后退按钮,其副作用是不再可以从左向右滑动以弹出视图控制器并导航回来.
原文链接:https://www.f2er.com/swift/319069.html所以我在自定义UINavigationController类中实现了interactivePopGestureRecognizer:
class UINavigationControllerExtended: UINavigationController,UIGestureRecognizerDelegate { override func viewDidLoad() { super.viewDidLoad() if self.respondsToSelector(Selector("interactivePopGestureRecognizer")) { self.interactivePopGestureRecognizer?.delegate = self } } func gestureRecognizer(gestureRecognizer: UIGestureRecognizer,shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { return true } func gestureRecognizer(gestureRecognizer: UIGestureRecognizer,shouldBerequiredToFailByGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool { return gestureRecognizer.isKindOfClass(UIScreenEdgePanGestureRecognizer) } }
这工作正常,除非我在我的根视图控制器(RVC)中,它是一个UICollectionViewController,即导航堆栈中最底层的视图控制器.当我从左到右滑动手势时,似乎没有任何事情发生,正如预期的那样.但是当我点击UICollectionViewCell时,目标视图控制器(DVC)不会被推过RVC.相反,我只在屏幕右侧看到DVC的阴影.
RVC不再响应,但当我再次从左向右滑动时,DVC以交互方式从右向左移动到屏幕中.当我完成手势时,DVC完全移动到屏幕中,以便从左到右快速消失. RVC再次响应.
所以似乎DVC被推到了导航堆栈上,但没有明显地进入屏幕.
这个奇怪的行为起源的任何建议?