Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 无法在Swift中的UITableViewController中显示UIAlertController_Ios_Swift_Uialertcontroller - Fatal编程技术网

Ios 无法在Swift中的UITableViewController中显示UIAlertController

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

我有一个UIAlertController,我想在UITableViewController中演示它。但是,当我运行代码时,会出现以下错误:

警告:试图在上显示 谁的观点不在讨论中 窗口层次结构

我的代码似乎反映了本文的建议。我做错了什么

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中,窗口层次结构中仍然没有视图,如消息中所述。尝试将代码移动到视图显示,而不是

可能重复的