简体   繁体   English

UINavigationController 交互式流行手势仅在第一次有效

[英]UINavigationController Interactive Pop Gesture only works first time

I have been working on an app for some time and just realized the swiping back in the detail view only returns me to the master view the first time.我已经在一个应用程序上工作了一段时间,刚刚意识到在详细信息视图中向后滑动只会让我第一次返回主视图。 It also isn't smooth, even when it works on the first time.它也不是很顺利,即使它是第一次运行。 Instead of smoothly going to the master view, it jumps all at once, even when I swipe slowly.它不是顺利进入主视图,而是一下子跳转,即使我慢慢滑动也是如此。 It used to work correctly, but I haven't been testing for this specifically, so I don't know when it stopped working and what I changed to cause this.它曾经可以正常工作,但我没有专门为此进行过测试,所以我不知道它何时停止工作以及我更改了什么导致了这种情况。

A little about how my app is setup...关于我的应用程序如何设置的一点...

I have a split view controller that is connected to my MasterTableViewController and DetailViewController .我有一个连接到我的MasterTableViewControllerDetailViewController的拆分视图控制器。

Both of those are have TableViews and are embedded in Navigation Controllers.这两个都有 TableViews 并嵌入在导航控制器中。

I have set it up so that the app originally loads to the MasterTableViewController instead of going immediately to the DetailViewController, but even when I take this out, the interactive pop gesture doesn't work.我已经设置好应用程序最初加载到 MasterTableViewController 而不是立即转到 DetailViewController,但即使我取出它,交互式弹出手势也不起作用。

I don't believe I've messed with any of the back button controls.我不相信我弄乱了任何后退按钮控件。 I have looked through my code and storyboard and can't find anywhere that I have.我查看了我的代码和故事板,但找不到任何地方。 This is part of what is most confusing because these questions ( 1 , 2 , and 3 ) all seem to have problems stemming from changing the back button or can be fixed by entering the following line of code:这是最令人困惑的部分,因为这些问题( 123 )似乎都有来自更改后退按钮的问题,或者可以通过输入以下代码行来修复:

self.navigationController.interactivePopGestureRecognizer.delegate = nil

Adding that to my code seems to have no impact on how it behaves.将其添加到我的代码中似乎对其行为方式没有影响。

Here is a picture of how it is setup for reference:这是如何设置的图片以供参考: 在此处输入图片说明

I can usually figure out these things on my own, but this problem baffles me because it works the first time, but not any others.我通常可以自己解决这些问题,但这个问题让我感到困惑,因为它第一次有效,但其他任何时候都无效。 As far as I can tell, nothing changes between the first time and the others.据我所知,第一次和其他时间之间没有任何变化。 I don't know if anybody else has had the same issue, but any help on why this might be happening would be greatly appreciated.我不知道是否有其他人遇到过同样的问题,但是对于为什么会发生这种情况的任何帮助将不胜感激。 I can provide code or answers to questions on how I am doing certain things if needed.如果需要,我可以提供有关我如何做某些事情的问题的代码或答案。 I haven't put any in because there are so many different things controlling this piece that I don't know where to start.我没有放任何东西,因为控制这件作品的东西太多了,我不知道从哪里开始。

From Alex Chase's answer : Also check your overrides of viewWillAppear in child ViewControllers .来自Alex Chase 的回答:还要检查您在子ViewControllersviewWillAppear的覆盖。 This method gets called during an interactive pop.在交互式弹出期间调用此方法。

added it to viewWillAppear and it worked:将它添加到viewWillAppear并且它起作用了:

   override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        navigationController?.interactivePopGestureRecognizer?.delegate = self

    }

When are you calling self.navigationController.interactivePopGestureRecognizer.delegate = nil ?你什么时候调用self.navigationController.interactivePopGestureRecognizer.delegate = nil Doing this will definitely disable interactive pop.这样做肯定会禁用交互式流行音乐。 It sounds like you may be calling this after a certain UIViewController appears.听起来您可能会在某个UIViewController出现后调用它。

What other modifications to UINavigationController are you making?您对UINavigationController进行了哪些其他修改? Are you using appearance delegate?你在使用外观委托吗? Are you subclassing?你是子类化吗? If so, are you calling super in all of your method overrides?如果是这样,您是否在所有方法覆盖中调用super

Also check your overrides of viewWillAppear in child ViewControllers.还要检查您在子 ViewControllers 中对viewWillAppear的覆盖。 This method gets called during an interactive pop.在交互式弹出期间调用此方法。 If you are doing a lot of computation (or synchronous calls) on the main thread within this method, it could cause frame drop, hence the choppy animation.如果您在此方法中的主线程上进行大量计算(或同步调用),则可能会导致掉帧,从而导致动画断断续续。

Hope this helps希望这可以帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 UINavigationController 交互式流行手势不起作用? - UINavigationController Interactive Pop Gesture Not Working? UINavigationController - 获取交互式pop手势识别器进度 - UINavigationController - get interactive pop gesture recognizer progress UINavigationController交互式弹出手势取消在iOS 8中不起作用? - UINavigationController Interactive Pop Gesture cancellation Not Working in iOS 8? 将触摸转发到UINavigationController交互式弹出手势无法完全正常工作 - Forwarding touches to UINavigationController Interactive Pop Gesture Not completely Working 取消交互式UINavigationController pop手势不会调用UINavigationControllerDelegate方法 - Canceling interactive UINavigationController pop gesture does not call UINavigationControllerDelegate methods iOS Custom Gesture Recognizer仅适用于第一次 - iOS Custom Gesture Recognizer works only first time 提供自定义动画控制器时 UINavigationController 中的系统交互弹出手势中断 - System interactive pop gesture broken in UINavigationController when providing a custom animation controller iOS:UINavigationController交互弹出手势期间,导航栏的全角自定义titleView闪烁 - iOS: Full width custom titleView of navigation bar flickers during interactive pop gesture of UINavigationController UINavigationController类别具有自定义后退按钮的Pop手势 - UINavigationController Category Pop Gesture with Custom Back Button Xamarin iOS - 交互式流行手势识别器的实现 - Xamarin iOS - Implementation of Interactive Pop Gesture Recognizer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM