来自UIModalTransitionStylePartialCurl viewController的presentModalViewController
我有一个通过 UIModalTransitionStylePartialCurl 转换呈现的模式视图。在该模态视图中有一个按钮,我想:
- 关闭当前模态视图(向下卷曲),然后
- 呈现一个新的模态视图(垂直覆盖)。
然而,当我尝试以下操作时,它只是忽略了卷曲模式视图,但不显示新的视图:
[self dismissModalViewControllerAnimated:YES];
NewView *vc = [[NewView alloc] init];
[self.parentViewController presentModalViewController:vc animated:YES];
我有一种感觉,它与最后一行有关。在 self
上呈现 NewView 也不起作用。我怎样才能做到这一点?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用的是 iOS 5 吗?
如果是这样,您看到的问题是由于此处记录的更改所致: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/parentViewController
该链接的重要一点是:
因此,更改为 self.presentingViewController 可能会解决您的问题,但可能不会。
使用第一个模式中的此代码:
您看不到呈现的新视图控制器。
为了得到你想要的东西,你需要使用一个新的(从 iOS5 开始)方法:
这个方法是presentModalViewController 的推荐替代品。
第一个视图控制器上的自定义方法,类似于:
该方法既可以关闭当前模态,又可以呈现新模态,如下所示:
使用完成块启动新模态,让您等待旧模态动画结束。因此,在第二个模态视图控制器中,您将在第一个模态视图控制器上调用自定义方法,并让它管理消除/呈现新视图控制器。
Are you using iOS 5?
If so the problem you are seeing is due to a change documented here: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/parentViewController
The important bit at that link is this:
So changing to self.presentingViewController may fix your issue, but probably will not.
Using this code from your first modal:
You don't see the new view controller presented.
To get what you are after you want to use a new (as of iOS5) method:
This method is the recommended replacement for presentModalViewController.
And a custom method on your first view controller, something like:
That method can both dismiss your current modal and present the new one, something like this:
Using the completion block to launch the new modal let's you wait until the old modal has animated out. So in your second modal view controller you would call your custom method on your first modal view controller and let it manage dismissing/presenting the new one.
首先要验证的是 self.parentViewController 是否为零。
如果它是nil(在我的测试中它是nil),您将需要在该模式视图中传递一个指向您的父级的指针。
之后,您可以
在此处执行类似的操作
self.caller
是 UIViewController 上以模态呈现之前设置的“父级”。我不认为这是一个完美的解决方案,但它在我的测试中有效。
The first thing to verify would be if
self.parentViewController
is nil or not.if it's
nil
(in my test it was nil) you will need to pass a pointer to your parent in that modal view.And after that you could do something like this
here
self.caller
is the "parent" that was set on the UIViewController just before it was presented modally.I don't find this to be a perfect solution, but it's working in my test.