短:
从func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
UINavigationControllerDelegate
导致edge-swipe-pop功能不起作用
稍长一点:我正在实现上面提到的委托方法来确定呈现的viewcontrollers状态,这部分效果很好。我在方法中返回nil,因为我实际上不需要任何animationController用于花式效果。但是实现此方法会导致边缘滑动弹出功能/手势不起作用。我尝试使用各种方法获得默认行为,例如实现animationcontrollers或interactivecontroller,甚至尝试获取默认动画/交互式控制器,但这也不起作用。我可以将gesturerecognizer应用于整个视图,但这不是预期的行为。
是否有人遇到类似问题,是否有解决此问题的方法我不知道?
这是一个NavigationController的例子:
class MyNavigationController: UINavigationController {
override init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?) {
super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
delegate = self
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension MyNavigationController: UINavigationControllerDelegate {
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
//removing or commenting out this method enables the edge-swipe-back feature/gesture
return nil
}
}
答案 0 :(得分:0)
在init
方法中,您需要设置:
self.interactivePopGestureRecognizer.delegate = self
这将重新启用此功能。