UIViewController's viewDidAppear not being called after a modal close

别说谁变了你拦得住时间么 提交于 2019-12-06 06:04:53

问题


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];
}


来源:https://stackoverflow.com/questions/3818614/uiviewcontrollers-viewdidappear-not-being-called-after-a-modal-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!