TFL*_*9Z1 1 ios appdelegate swift uialertcontroller
我尝试在我的应用程序委托中创建弹出警报消息,但它根本没有显示。程序是用Swift 4编写的。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let alert = UIAlertController(title: "title", message: "message", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil))
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
告诉委托人启动过程即将完成并且应用程序即将准备好运行。
所以我认为你不能在 中显示警报didFinishLaunchingWithOptions。
尝试将您的代码移至applicationDidBecomeActive.
| 归档时间: |
|
| 查看次数: |
955 次 |
| 最近记录: |