仅在另一个视图控制器被关闭之后才呈现模态视图控制器 [英] Presenting a modal view controller only after another one has been dismissed

查看:89
本文介绍了仅在另一个视图控制器被关闭之后才呈现模态视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能只是做

[myViewController dismissModalViewControllerAnimated:YES];
[myViewController presentModalViewController:nextModalViewController animated:YES];

一个接着一个,因为两个动画块试图同时影响相同的引用,糟糕。

one after the other, because then the two animation blocks try to affect the same references simultaneously and things break badly.

因此,我需要做的是仅在第一个动画完成后才调用后者。但是没有 UIViewControllerDelegate 方法,如 didDismissModalViewController 。我应该怎么办?

So what I need to do is make the latter call only after the first animation has finished. But there's no UIViewControllerDelegate method like didDismissModalViewController. What should I do?

推荐答案

只是子类化视图控制器(如果你还没有)

What's wrong with just subclassing the view controller (if you haven't already) and doing this:

 - (void) viewDidDisappear: (BOOL) animated
 {
     [super viewDidDisappear: animated];


     [myViewController presentModalViewController:nextModalViewController animated:YES];
 }



我不知道你是如何处理你对视图控制器的引用,但是我想要做的只是捕捉viewDidDisappear为滑动的模型视图控制器。

I'm not sure how you are handling your references to the view controllers, but the point I'm trying to make is just catch the viewDidDisappear for the model view controller that is sliding off.

这篇关于仅在另一个视图控制器被关闭之后才呈现模态视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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