viewDidDisappear not getting called on a UINavigationController

前端 未结 4 846
无人及你
无人及你 2021-01-27 20:25

I\'m having a problem with my navigation controller. If I add a view controller to the stack:

- (void) tui_ToggleListStudy:(id)sender
{
    listVC = [[ListViewCo         


        
相关标签:
4条回答
  • 2021-01-27 20:33

    You must call super at implementation of viewWillDisappear.

    0 讨论(0)
  • 2021-01-27 20:35

    The designated initializer for UIViewController is -initWithNibName:bundle:. Are you sure your view controller is finding its nib and finds its connected view? I'll bet if you set a breakpoint after init'ing your ListViewController, you'll find its -view returns nil.

    0 讨论(0)
  • 2021-01-27 20:37

    Assuming your navigation controller is contained in some kind of top view controller, you must also forward the relevant messages from that top view controller to the nav controller:

    -(void)viewWillAppear:(BOOL)animated
    {
        [navController viewWillAppear:animated];
    }
    
    -(void)viewDidAppear:(BOOL)animated
    {
        [navController viewDidAppear:animated];
    }
    
    -(void)viewWillDisappear:(BOOL)animated
    {
        [navController viewWillDisappear:animated];
    }
    
    -(void)viewDidDisappear:(BOOL)animated
    {
        [navController viewDidDisappear:animated];
    }
    
    0 讨论(0)
  • 2021-01-27 20:51

    I know the answer if you made the same typo in your code that you made in your question: the method signature is viewDidDisappear: (with the animated argument), not viewDidDisappear.

    Not only that, but the view controller doesn't receive any other delegate messages either: No viewDidUnload, or dealloc...

    A view controller will not be deallocated when you push another controller onto the stack. And viewDidUnload won't be called unless you run out of memory.

    0 讨论(0)
提交回复
热议问题