iphone - 一段时间后关闭 ViewController?

标签 iphone objective-c ios uiviewcontroller

有没有办法让我在 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/

相关文章:

android - 获取android/iphone到服务器的准确时间

objective-c - 为什么找不到 Swift 4 语言的 Xcode objective-c 接口(interface) header 名称

ios - 特定日期格式的日期格式化程序

ios - UITableViewCell 不显示 subview

java - 在 Android 和 iPhone 中使用 AES-128 加密(不同的结果)

iphone - UITableViewCell 设置选中图片

iphone - 使用Xcode播放随机声音

c# - 在代码中创建时的 UITableView 工件

ios - 无法移动 UIImageView

ios - UISearchBar 提示在导航栏中时没有动画