gpt4 book ai didi

应用程序委托(delegate)中的 iOS 弹出消息?

转载 作者:行者123 更新时间:2023-11-28 10:49:00 26 4
gpt4 key购买 nike

我尝试在我的应用委托(delegate)中创建一个弹出式警告消息,但它根本没有显示。该程序是用 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)
}

最佳答案

根据 the documentation for didFinishLaunching :

Tells the delegate that the launch process is almost done and the app is almost ready to run.

所以我认为您不能在 didFinishLaunchingWithOptions 中显示警报。

尝试将您的代码移动到 applicationDidBecomeActive

关于应用程序委托(delegate)中的 iOS 弹出消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47008830/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com