iPad viewWillAppear 和presentModalViewController 问题
在iPhone中,我有一个表格视图,触摸单元格,我有一个方法调用presentModalViewController,并打开另一个视图,其中包含电子邮件和此类内容。 当用户按下取消按钮时,将调用上一个视图中的 viewWillAppear 方法。 到目前为止,一切都很好。但在iPad中,viewWillAppear仅在视图第一次出现时被调用,有人知道这是一个错误还是正确的? 我尝试实施
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
但没有成功。
有谁知道如何解决这个问题而不需要从头开始执行任何委托方法? 提前致谢
In the iPhone, I have a tableview, and touching the cells, I have one method calling presentModalViewController, and opening another view, with email and this kind of stuff.
When the user press the cancel button, the viewWillAppear method in the previous view is called.
So far, so good. But in the iPad, the viewWillAppear is only called the first time that the view appears, anyone knows if this is a bug or it's right?
I tried to implement the
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
with no success.
Does anybody know how to fix this without doing any delegate method from scratch?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于以模态方式呈现的视图控制器不一定完全覆盖 iPad 上的底层视图,因此当所述模态视图控制器被关闭时, viewWillAppear 方法不会触发。我依靠委托方法向原始视图控制器宣布模态视图控制器的操作。我认为这是最好的方法。
Since view controllers presented modally don't necessarily completely cover up the underlying view on iPad, the viewWillAppear method does not fire when said modal view controllers get dismissed. I rely on delegate methods to announce to the original view controller the actions of the modal view controller. I think it's the best way to go.
基于猜测,而不是阅读、测试或任何真正有用的东西,但因此未涵盖在 NDA 中...
当您呈现 ModalViewController 时是否调用 viewWillDisappear ?可能它不认为模态视图完全遮挡原始视图,因此(与 iPhone 不同)两者同时存在?
Based on guesswork, rather than reading, testing or anything useful really, but therefore not covered under the NDA...
Is viewWillDisappear being called when you presentModalViewController ? It may be that it doesn't think the modal view obscures the original view fully, therefore (unlike the iPhone) both exist at once ?
很可能这是一个错误,我会在此处向苹果提交错误报告。
Chances are it's a bug, I would file a bug report with apple here.