模态关闭后未调用UIViewController的viewDidAppear [英] UIViewController's viewDidAppear not being called after a modal close
问题描述
UIViewController(视图A)通过将其作为模式控件调用来调用另一个视图控制器(视图B).
A UIViewController (View A) invokes another view controller (View B) by invoking it as a modal control.
[self presentModalViewController:ViewB animation:TRUE];
[self presentModalViewController:ViewB animated:TRUE];
视图B通过调用而存在:
And View B exists by invoking:
[self dismissModalViewControllerAnimated:TRUE];
[self dismissModalViewControllerAnimated:TRUE];
发生这种情况时,所有内容看起来都正确,除了不调用View A的viewWillAppear和viewDidAppear(尽管它们在应用程序初始化期间被调用).奇怪的是...我相信香港专业教育学院以前曾做过此事,但我不确定现在正在发生什么.
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!
*更新* 我刚刚了解到,此行为仅在UIModalTransitionStylePartialCurl过渡类型下发生.对于所有其他过渡类型,父级视图控制器可以很好地获取其viewDidAppear消息.
* 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!?!
推荐答案
我只是遇到了同样的问题.
I just ran in to the same problem.
我通过添加一个委托和一个委托方法解决了它.
I solved it by adding a delegate and a delegate method.
因此,当控制器A将控制器B作为具有页面卷曲的模式视图控制器打开时,我将控制器b..delegate的实例设置为控制器a.
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.
在控制器B中,我添加以下内容:
In controller B i add this:
-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
if (delegate)
[delegate didCloseInfoViewController];
}
这篇关于模态关闭后未调用UIViewController的viewDidAppear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!