2012-07-02 38 views
0

我有一个模式,它为我的iPad应用程序的一些选项。当选择一个选项时,我想删除模态,然后继续到新的屏幕。睡眠命令不工作

我想让原始屏幕(即启动模式)在新赛事发生之前持续两秒钟。为什么这个代码不起作用?

[self dismissModalViewControllerAnimated:YES]; 
sleep(2.0); 
[self performSegueWithIdentifier:@"normalPushSegue" sender:self]; 

这是发生了什么:当按下的模式按钮冻结两秒钟,然后转换非常快的normalPushSegue屏幕。即使我把睡眠命令放入prepareForSegue,它仍然会做同样的事情。

任何想法?有没有其他方法可以延缓赛季?

+0

也许看这里! http://jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/ – trumpetlicks

+0

永远不要使用睡眠() – Dancreek

+0

对不起,我基于它的使用: http://stackoverflow.com/questions/10025423/how-to-perform-segue-with-delay 不会再使用它:) – Firo

回答

1

使用performSelector:afterDelay:代替:

[self performSelector:@selector(performSegueWithIdentifier::) withObject:@"normalPushSegue" withObject:self afterDelay:2];