0

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.

Both of those are have TableViews and are embedded in Navigation Controllers.

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.

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:

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: enter image description here

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.

MichaelLink
  • 179
  • 11
Taylor
  • 733
  • 7
  • 18

2 Answers2

0

When are you calling 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.

What other modifications to UINavigationController are you making? Are you using appearance delegate? Are you subclassing? If so, are you calling super in all of your method overrides?

Also check your overrides of viewWillAppear in child ViewControllers. 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

Alex Chase
  • 960
  • 1
  • 7
  • 11
  • I was putting self.navigationController.interactivePopGestureRecognizer.delegate = nil in a class I made for the navigation controller – Taylor Jun 20 '18 at 07:21
  • I haven't done anything else to the UINavigationController, not subclassing it at all – Taylor Jun 20 '18 at 07:22
  • And, its not that the animation is choppy, it is just quick. As soon as I start the gesture, it finishes the animation instead of letting me sort-of pull the MasterTableView over from the side. – Taylor Jun 20 '18 at 07:23
  • Remove `self.navigationController.interactivePopGestureRecognizer.delegate = nil` and see if that fixes it – Alex Chase Jun 20 '18 at 07:30
  • Nope, I had added that attempting to fix it and it had no effect. After removing, it still doesn't work – Taylor Jun 20 '18 at 07:32
0

From Alex Chase's answer : Also check your overrides of viewWillAppear in child ViewControllers. This method gets called during an interactive pop.

added it to viewWillAppear and it worked:

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

    }
jidicula
  • 3,454
  • 1
  • 17
  • 38
Aalaa
  • 55
  • 6