【发布时间】:2017-01-19 09:30:12
【问题描述】:
我有一个 UIAlertController,我想在 UITableViewController 中展示它。但是,当我运行代码时,出现以下错误:
警告:尝试在 谁的观点不在 窗口层次结构!
我的代码似乎反映了answer 中的建议。我做错了什么?
override func viewDidLoad() {
super.viewDidLoad()
// Check for force touch feature, and add force touch/previewing capability.
if traitCollection.forceTouchCapability == .available {
registerForPreviewing(with: self, sourceView: view)
}
else {
// Create an alert to display to the user.
alertController = UIAlertController(title: "3D Touch Not Available", message: "Unsupported device.", preferredStyle: .alert)
self.present(alertController!, animated: false, completion: nil)
}
【问题讨论】:
标签: ios swift uialertcontroller