【发布时间】:2015-09-27 16:32:02
【问题描述】:
我想在互联网连接不可用时加载警报。检查互联网连接的功能已准备就绪,但我无法加载警报。所以我只是在没有任何条件等的情况下将警报代码放在 viewDidLoad 中并得到了这个错误:
警告:尝试在 x.ViewController: 0x127646f00 上呈现 UIAlertController: 0x12752d400,其视图不在窗口层次结构中!
代码:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// Delegates
verificationCode.delegate = self
let alert = UIAlertController(title: "Oops!", message:"This feature isn't available right now", preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default) { _ in }
alert.addAction(action)
self.presentViewController(alert, animated: true) {}
if (!Util.isConnectedToNetwork()) {
self.isConnected = false
}
}
你能告诉我如何解决它吗?
【问题讨论】:
标签: swift2 ios9 uialertcontroller