English 中文(简体)
iPad-当有多个模式时,最上面的模式视图控制器不会关闭
原标题:iPad - topmost modal view controller won t dismiss when there are multiple

我正在开发iPad/iPhone双应用程序。

我遇到了一个仅在iPad上出现的问题:

  • Root view controller is a UISplitViewController on iPad, UITabBarController on iPhone
  • A modal UIViewController can appear over the root controller
  • A modal UIViewController can appear over the previous modal controller
  • On iPad, modal controllers are using UIModalPresentationStyle.PageSheet

一切都正常,除了从iPad中移除最顶层的模态控制器——方法被调用,但模态视图控制器不会移除。我通过从上一个模态控制器调用DismissModalViewControllerAnimated来解除。

你知道为什么这在iPad上不起作用吗?

在所有情况下,我从父控制器调用PresentModalViewController和DismissModalViewControllerAnimated来处理其子模式控制器。

我使用的是MonoTouch(你可以通过我的方法来判断),但这可能无关紧要。我也可以接受Obj-C中的答案。

更新,以下内容可能会使它应该做的事情更加清楚:

  • Root => Modal A => Modal B
  • Dismissing Modal B should just return to Modal A
  • Dismissing Modal A should just return to Root
最佳回答

找到了解决方法。必须满足所有这些条件才能修复它:

  1. First modal has default ModalPresentationStyle
  2. Second modal has UIModalPresentationStyle.PageSheet
  3. My second modal is displayed in the ViewDidAppear of the first. For some reason, I needed to call PresentModalViewController from BeginInvokeOnMainThread. (A one-liner in MonoTouch) This is a trick I learned from Windows development and message pumps. I have seen iPhone devs do similar workarounds with timers--this is much better.

如果我们在应用商店中遇到问题,我会回复的。但就目前而言,这对我们来说是一个很好的解决方案。

问题回答

你确定你否定了正确的观点吗?在模态视图中,假设您想通过单击按钮来关闭视图。在该按钮的方法中,您希望调用DismissModalViewControllerAnimated方法。只是说

[self dismissModalViewControllerAnimated:YES];
  • Present the modal window from the root
  • when finished, dismiss the view from the modal view s controller.

如果没有看到你试图如何呈现和消除控制器,很难真正诊断出问题,但这应该有效。一旦显示新视图,就不需要从父控制器执行任何操作。。。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签