iOS 5 : -viewWillAppear is not called after dismissing the modal in iPad(iOS 5:在 iPad 中关闭模式后不调用 -viewWillAppear)
问题描述
我正在使用以下代码呈现模态:
I am presenting modal using the following code :
AddName *add = [[AddName alloc] initWithNibName:@"AddName" bundle:nil]
add.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalView:add animated:YES];
在我工作之后,我使用以下代码返回我的主视图.
And After my work I use following code to go back on my main view.
[self dismissModalViewControllerAnimated:YES];
所以默认调用-viewWillAppear
.
我的问题是,
在 iOS4.3 上运行良好.
但它不适用于 iOS5.
我该怎么办?或者这是 iOS5 中的任何错误吗?
What should I do ? Or Is that any bug in iOS5?
推荐答案
-viewWillAppear
只保证在 -viewWillDisappear
也被调用的地方被调用.对于 iPad 上的大多数模式窗口,情况并非如此,因为它们不会遮挡整个页面.
-viewWillAppear
is only guaranteed to be called in places where the -viewWillDisappear
has also been called. For most modal windows on the iPad, this is not the case, since they don't obscure the entire page.
您的问题的解决方案将取决于您需要 -viewWillAppear
来做什么,但一般来说,您可能需要直接从您关闭模式的同一个地方拨打电话视图控制器.
The solution to your problem will depend on what you need the -viewWillAppear
for, but in general, you're likely to need to make a call directly from the same place that you dismiss the modal view controller.
一种常见的机制,尤其是在您可能在其他地方使用相同的模态视图的情况下,是给模态视图控制器一个委托,当视图即将消失时调用该委托.这将使您有机会从模态窗口中获取响应,甚至只是在委托视图中强制重新加载数据.
One common mechanism for this, especially in cases where you might use that same modal view somewhere else, is to give the modal view controller a delegate which is called when the view is about to disappear. This will give you a chance to take the responses from the modal window, or even just force a data reload in the delegate view.
希望这会有所帮助.
这篇关于iOS 5:在 iPad 中关闭模式后不调用 -viewWillAppear的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 5:在 iPad 中关闭模式后不调用 -viewWillAppear


基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01