iOS 5:在解除iPad中的模态后不调用-viewWillAppear [英] iOS 5 : -viewWillAppear is not called after dismissing the modal in iPad

查看:726
本文介绍了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 by默认。

So it use to call -viewWillAppear by default.

我的问题是,

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 for,但一般情况下,你可能需要直接从你解雇模态视图控制器的同一个地方拨打电话。

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆