0

我正在尝试在alertView2 可见通知/控制中心之前添加一个buttons。一个button是“好的”,然后通知/控制中心应该打开。第二个button应该是取消,不应该显示通知/控制中心。

我尝试像这样添加alertView一个applicationWillResignActive

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没有通知/控制中心打开的情况下制作节目?

4

1 回答 1

0

您的 AlertView 正在显示,因为您的应用程序将在通知中心显示时退出活动状态,并且您正在从处理此转换的 appDelegate 方法启动它。

你想要完成什么?无法让您的应用阻止通知中心显示,或从 AlertView 以编程方式打开它。

您可以查看表 2-3 中的 iOS 应用程序状态:

iOS 应用生命周期

于 2015-08-18T03:08:25.687 回答