Popping ViewController doesn't call viewWillAp

2019-01-25 18:19发布

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?)

2条回答
做个烂人
2楼-- · 2019-01-25 18:32

It will not get called because the view is inside the navigation controller, but I found a solution here:

http://davidebenini.it/2009/01/03/viewwillappear-not-being-called-inside-a-uinavigationcontroller/

Hope that helps.

查看更多
Viruses.
3楼-- · 2019-01-25 18:37

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

查看更多
登录 后发表回答