【发布时间】:2017-04-05 09:14:02
【问题描述】:
是否可以在 UIAlertAction 中添加 UIAlert 视图?
因为当我尝试在 UIAlertAction 中添加 UIAlert 视图时,它说
"警告:尝试在其视图不在窗口中进行展示 等级制度!”
这是我的代码。
let myAlert = UIAlertController(title: "Title", message: "title here", preferredStyle: UIAlertControllerStyle.alert)
let okaction = UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler:
{
action in
let myViewController:ViewController = self.storyboard!.instantiateViewController(withIdentifier: "ViewController") as! ViewController
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let navigationController = UINavigationController.init(rootViewController: myViewController)
appDelegate.window?.rootViewController = navigationController
appDelegate.window?.makeKeyAndVisible()
if (statement here == 1) {
let myAlert = UIAlertController(title: "Title", message: "title", preferredStyle: UIAlertControllerStyle.alert)
myAlert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: nil))
self.present(myAlert, animated: true, completion: nil)
return
}
}
)
myAlert.addAction(okaction)
self.present(myAlert, animated: true, completion: nil)
【问题讨论】:
标签: swift3 appdelegate uialertcontroller uialertaction