Ios 无法在Swift中的UITableViewController中显示UIAlertController
我有一个UIAlertController,我想在UITableViewController中演示它。但是,当我运行代码时,会出现以下错误: 警告:试图在上显示 谁的观点不在讨论中 窗口层次结构 我的代码似乎反映了本文的建议。我做错了什么Ios 无法在Swift中的UITableViewController中显示UIAlertController,ios,swift,uialertcontroller,Ios,Swift,Uialertcontroller,我有一个UIAlertController,我想在UITableViewController中演示它。但是,当我运行代码时,会出现以下错误: 警告:试图在上显示 谁的观点不在讨论中 窗口层次结构 我的代码似乎反映了本文的建议。我做错了什么 override func viewDidLoad() { super.viewDidLoad() // Check for force touch feature, and add force touch/previewing capabi
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)
}
假设,在viewDidLoad中,窗口层次结构中仍然没有视图,如消息中所述。尝试将代码移动到视图显示,而不是可能重复的