- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
短:实现 func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
from UINavigationControllerDelegate
导致边缘滑动弹出功能不起作用
有点长:我正在实现上面提到的委托(delegate)方法来确定呈现 View Controller 的状态,这部分效果很好。我在方法内部返回 nil,因为我实际上不需要任何 animationController 来实现花哨的效果。但是实现此方法会导致边缘滑动弹出功能/手势不起作用。我尝试通过各种方法获取默认行为,例如实现动画 Controller 或交互 Controller ,甚至尝试获取默认动画/交互 Controller ,但这也不起作用。我可以将手势识别器应用于整个 View ,但这不是预期的行为。
有没有人遇到过类似的问题,是否有我不知道的解决方案?
以 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
}
}
最佳答案
在您的init
方法中,您需要设置:
self.interactivePopGestureRecognizer.delegate = self
这将重新启用此功能。
关于swift - 实现 UINavigationControllerDelegates animationControllerFor 方法禁用边缘滑动弹出功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40239705/
短:实现 func navigationController(_ navigationController: UINavigationController, animationControllerFo
我是一名优秀的程序员,十分优秀!