5

Whenever I pop a view controller manually, viewWillAppear doesn't get called on the previous UIViewController that now appears.

These are 2 regular UIViewControllers. My application setup is like this:

- UINavigationController
   - UITabViewController with 5 UIViewControllers including UIViewControllerA
      -UIViewControllerA (When I get back here, viewWillAppear doesnt get called)
        -UIViewControllerB (I'm here, I want to pop to A)

I've tried calling viewWillAppear manually, but that doesn't help either. What could be wrong? My last resort will be popping B, and A, and then creating a new A, and pushing that, but that's only as a last resort(I assume this will work?)

rptwsthi
  • 10,094
  • 10
  • 68
  • 109
Henley
  • 21,258
  • 32
  • 119
  • 207
  • if it's a modal then viewwillappear won't be called. That's how the architecture is. You need to create a delegate in Modal and implement it in the parent ViewController. So when something happens in the model viewcontroller you can tracethem back in parent ViewController. – Jay Mayu Jul 09 '15 at 04:49

2 Answers2

3

You cannot have a UITabBarController "inside" of a UINavigationController. That's probably why some of the viewWillAppear methods aren't being called. Take a look here: Tab bar controller inside a navigation controller, or sharing a navigation root view

Community
  • 1
  • 1
Daniel Dickison
  • 21,832
  • 13
  • 69
  • 89
1

I have created this class that solves your problem. I have used it in many of my own projects.

Just set it as a delegate of your navigation controller, and implement simple one or two methods in your view controller - that will get called when the view is about to be shown or has been shown via NavigationController

Here's the GIST showing the code

GregJaskiewicz
  • 456
  • 3
  • 11