有没有办法让我在 5 秒后展示或关闭我的 ViewController?也许像......如果用户在 5 秒后按下按钮,则会出现新 View 。
有什么解决方案或建议吗?抱歉,我没有在网上找到解决方案。
我的代码不起作用:
-(IBAction)lol:(id)sender {
[self performSelector:@selector(dissMissviewController) withObject:self afterDelay:3];
}
-(void)dissMissViewController{
[self dismissModalViewControllerAnimated:YES];
}
谢谢。
最佳答案
你可以用下面一个..
//for dismissing the ViewControler on clicking button just use below piece of code.
[self performSelector:@selector(dismissViewController) withObject:self afterDelay:5];
//dismissviewController is the method which has the code for dismissing the viewController.
//and can follow the same for showing the viewController.
- (void)dismissViewController
{
//if you are pushing your viewControler, then use below single line code
[self.navigationController popViewControllerAnimated:YES];
//if you are presnting ViewController modally. then use below code
[self dismissModalViewControllerAnimated:YES];
}
我希望它可以清除给你......!
关于iphone - 一段时间后关闭 ViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13366080/