一段时间后解除ViewController?

Mas*_*zer 1 iphone objective-c uiviewcontroller ios

有没有办法,我可以在5秒后呈现或解散我的ViewController?也许是......如果用户在5秒后按下按钮,则会出现新视图.

任何解决方案或建议?抱歉,我没有在网上找到解决方案.

我的代码不起作用:

    -(IBAction)lol:(id)sender {

    [self performSelector:@selector(dissMissviewController) withObject:self afterDelay:3];
}

-(void)dissMissViewController{

    [self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

Kam*_*had 5

你可以使用下面一个..

//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];
 }
Run Code Online (Sandbox Code Playgroud)

我希望它可以清除给你...... !!!