我的 iPad 应用程序有一个带有一些选项的模式。当选择一个选项时,我想删除模式然后转到新屏幕。
我希望在新的转场发生之前可以看到原始屏幕(启动模式)两秒钟。为什么这段代码不起作用?
[self dismissModalViewControllerAnimated:YES];
sleep(2.0);
[self performSegueWithIdentifier:@"normalPushSegue" sender:self];
事情是这样的:当按下模态上的按钮时,它会卡住两秒钟,然后极快地转换到 normalPushSegue
屏幕。即使我将 sleep 命令放入 prepareForSegue
中,它仍然会执行相同的操作。
有什么想法吗?还有其他方法可以延迟转场吗?
最佳答案
使用performSelector:afterDelay:
代替:
[self performSelector:@selector(performSegueWithIdentifier::) withObject:@"normalPushSegue" withObject:self afterDelay:2];
关于ios - sleep 命令不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11297375/