<分区>
我正在学习 iOS 开发,我试图在用户首次启动该应用程序时查看提醒,然后再也不会。所以,我在我的应用程序委托(delegate)中写了这个:
func applicationDidBecomeActive(_ application: UIApplication) {
let alert = UIAlertController(title: "Alert Title", message: "Alert Message", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Okay", style: .cancel, handler: nil))
self.window?.rootViewController?.present(alert, animated: true, completion: nil)
此代码可用于查看警报,但我遇到的问题是每次启动应用程序时都会显示警报。那么有人可以帮忙吗?将不胜感激。