【问题标题】:UINavigationController's interactivePopGestureRecognizer not workingUINavigationController 的 interactivePopGestureRecognizer 不工作
【发布时间】:2014-07-19 14:45:39
【问题描述】:

在将一个特定的视图控制器推送到导航控制器的导航堆栈时,我正在尝试实现一个自定义 id <UIViewControllerAnimatedTransitioning> 对象。

但是,我发现这样做会阻止 UINavigation 控制器使用默认的交互式转换,即使在不使用我的自定义转换的视图控制器上

我不知道为什么会这样。

经过进一步调查,我发现从方法返回 nil

- (id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                               animationControllerForOperation:(UINavigationControllerOperation)operation
                                            fromViewController:(UIViewController *)fromVC
                                              toViewController:(UIViewController *)toVC

不知何故也禁用了默认的交互式过渡。

如何在某些情况下继续使用 UINavigationController 的默认交互式转换,同时在其他情况下使用自定义转换对象?

【问题讨论】:

  • 你想问什么问题?
  • 我遇到了这个确切的问题。希望有比发布的更好的解决方案。
  • 当我不想要自定义转换时,我最终将代理设置为 nil。

标签: ios objective-c cocoa-touch uiviewcontroller uinavigationcontroller


【解决方案1】:

这是一个blog post,详细说明了一个可能的解决方案。我还没有测试过。似乎是一个非常骇人听闻的解决方法。正如作者所说,如果 Apple 做出改变,它可能会崩溃,但是,嘿。

引用:

我最终做的是创建一个新的实例 UIScreenEdgePanGestureRecognizer,用左边缘和 设置与我们完全相同的目标/动作 interactivePopGestureRecognizer,换句话说,实例 _UINavigationInteractiveTransition 和动作 handleNavigationTransition:。最后将其添加到 UINavigationControllers 查看。有一点-valueForKey:NSSelectorFromString() 在最终解决方案中我不是很自豪 的,但它完美地工作。请记住在实施 像这样的解决方案,众所周知,Apple 改变了东西。

【讨论】:

    猜你喜欢
    • 2014-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-28
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多