在 appDelegate 中显示 alertView
Show alertView in appDelegate
我正在尝试在 notification/control 中心可见之前添加一个 alertView
2 buttons
。一个 button
将是 "ok",然后 notification/control 中心应该打开。第二个button
要取消,notification/control中心不显示。
我尝试在 applicationWillResignActive
中添加一个 alertView
,如下所示:
func applicationWillResignActive(application: UIApplication) {
var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
当用户尝试打开 notification/control 中心时,它会稍微打开,然后关闭并显示 alertView
。我如何在没有 notification/control 中心开口的情况下制作 alertView
节目?
您的 AlertView 正在显示,因为您的应用程序即将退出活动状态,因为通知中心正在显示,并且您正在从处理此转换的 appDelegate 方法启动它。
您想要完成什么?不可能让您的应用程序阻止通知中心显示,或以编程方式从 AlertView 打开它。
您可以在 table 2-3 中查看 iOS 应用程序状态:
我正在尝试在 notification/control 中心可见之前添加一个 alertView
2 buttons
。一个 button
将是 "ok",然后 notification/control 中心应该打开。第二个button
要取消,notification/control中心不显示。
我尝试在 applicationWillResignActive
中添加一个 alertView
,如下所示:
func applicationWillResignActive(application: UIApplication) {
var alert = UIAlertController(title: "Alert", message: "Message", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
当用户尝试打开 notification/control 中心时,它会稍微打开,然后关闭并显示 alertView
。我如何在没有 notification/control 中心开口的情况下制作 alertView
节目?
您的 AlertView 正在显示,因为您的应用程序即将退出活动状态,因为通知中心正在显示,并且您正在从处理此转换的 appDelegate 方法启动它。
您想要完成什么?不可能让您的应用程序阻止通知中心显示,或以编程方式从 AlertView 打开它。
您可以在 table 2-3 中查看 iOS 应用程序状态: