UIViewController's viewDidAppear not being cal

2019-04-10 11:40发布

问题:

A UIViewController (View A) invokes another view controller (View B) by invoking it as a modal control.

[self presentModalViewController:ViewB animated:TRUE];

And View B exists by invoking:

[self dismissModalViewControllerAnimated:TRUE];

When this occurs everything looks right EXCEPT that View A's viewWillAppear and viewDidAppear does not get called (they are called during app init though). Weird thing is... i believe ive done this before, but im not sure what is going on now.

Is there anything obviously wrong that im doing? Thanks!

* UPDATE * I just now learned that this behavior only occurs with the UIModalTransitionStylePartialCurl transition type. For all other transition types the parent view-controller gets its viewDidAppear message just fine.

So now what am i suppose to do!?!

回答1:

I just ran in to the same problem.

I solved it by adding a delegate and a delegate method.

So when Controller A opens Controller B as a modal view controller with a page curl i set the instance of controller b's.delegate to be controller a.

In controller B i add this:

-(void) viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    if (delegate)
        [delegate didCloseInfoViewController];
}