viewDidAppear not getting called

后端 未结 8 1036
醉酒成梦
醉酒成梦 2021-01-12 00:17

In my main UIViewController I am adding a homescreen view controller as subviews:

   UINavigationController *controller = [[UINavigationController alloc] ini         


        
8条回答
  •  天命终不由人
    2021-01-12 00:36

    The only way I can reproduce the problem of child controllers not receiving appearance methods is if the container view controller does the following (which I'm sure you're not doing):

    - (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
    {
        return NO;
    }
    

    Perhaps you can try explicitly enabling this:

    - (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers
    {
        return YES;
    }
    

    But my child view controllers definitely are getting the viewWillAppear calls (either if I explicitly automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers or if I omit this altogether.

    Update:

    Ok, looking at the comments under your original question, it appears that the issue is that the child controller (B) in question is, itself, a container view controller (which is perfectly acceptable) presenting another child controller (C). And this controller B's own child controller C is being removed and you're wondering why you're not getting viewWillAppear or viewDidAppear for the container controller B. Container controllers do not get these appearance methods when their children are removed (or, more accurately, since containers should remove children, not children removing themselves, when the container removes a child, it does not receive the appearance methods).

    If I've misunderstood the situation, let me know.

提交回复
热议问题