我想在用户打开应用程序时显示一个 UIAlertController
。
这就是我创建并尝试展示它的方式:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//simple alert dialog
let alert=UIAlertController(title: "Alert 1", message: "One is awesome", preferredStyle: UIAlertControllerStyle.Alert);
//show it
showViewController(alert, sender: self);
}
}
为什么不显示?
最佳答案
如果您使用:presentViewController(alert, animated: true, completion: nil)
正如@matt 所说,最好在 ViewDidAppear 中呈现您的 alertViewController 而不是 ViewDidLoad,因为呈现的 viewController 位于界面中。
关于ios - 为什么我的 UIAlertController 没有被解雇?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38815766/