【发布时间】:2019-11-30 17:14:02
【问题描述】:
我有一个UINavigationController 的自定义子类,它将自己设置为UINavigationControllerDelegate,并有条件地返回一个自定义动画师。我希望能够使用布尔标志在自定义动画师和系统动画之间切换。我的代码如下所示:
class CustomNavigationController: UINavigationControllerDelegate {
var useCustomAnimation = false
private let customAnimator = CustomAnimator()
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationController.Operation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
if useCustomAnimation {
return CustomAnimator()
}
return nil
}
}
但是,当useCustomAnimation 为false 时,系统管理的交互式返回手势不再起作用。与系统动画相关的所有其他内容仍然有效。
我尝试将交互式弹出手势的委托设置为我的自定义导航控制器,并从一些成功程度不同的方法返回真/假。
【问题讨论】:
标签: ios swift uinavigationcontroller uikit