我试图在通知/控制中心通过 2 个按钮
可见之前添加一个 alertView
。一个按钮
就是“确定”,然后通知/控制中心应该打开。应取消第二个按钮
,并且不应显示通知/控制中心。
我尝试在 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)
}
当用户尝试打开通知/控制中心时,它会稍微打开,然后关闭并显示 alertView
。如何在不打开通知/控制中心的情况下显示 alertView
?
最佳答案
显示您的 AlertView 是因为您的应用程序即将在通知中心显示时退出事件状态,并且您正在从处理此转换的 appDelegate 方法启动它。
你想要实现什么目标?您的应用程序无法阻止通知中心显示,也无法从 AlertView 以编程方式打开它。
您可以查看表2-3中的iOS应用程序状态:
关于ios - 在appDelegate中显示alertView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32062665/