ios - 由于未捕获的异常 'NSInternalInconsistencyException' 错误而终止应用程序

标签 ios xcode swift

class HomeViewController: UIViewController {

    @IBOutlet weak var userNameLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Show the current visitor's username
        if let pUserName = PFUser.currentUser()?["username"] as? String {
            self.userNameLabel?.text = "@" + pUserName
        }
    }

    override func viewWillAppear(animated: Bool) {
        if (PFUser.currentUser() == nil) {
            dispatch_async(dispatch_get_main_queue(), { () -> Void in

                let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("Login")
                self.presentViewController(viewController, animated: true, completion: nil)
            })
        }

    }
    @IBAction func commentAction(sender: AnyObject) {

        self.performSegueWithIdentifier("CommentSegue", sender: self)
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if segue.identifier == "CommentSegue"{

            let summaryView = segue.destinationViewController as? TableViewController

        }

    }

   }

我得到的错误是:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-tCJ-qt-q4b" from storyboard "Main", but didn't get a UITableView.'

有人知道我该如何解决这个问题吗?

最佳答案

您创建的 Controller 是 UITableViewController 或其子类。该错误告诉您该 Controller 的顶级 View 不是 UITableView

您需要修复 Storyboard中 View Controller 的链接,或者将 Controller 更改为其他类。

关于ios - 由于未捕获的异常 'NSInternalInconsistencyException' 错误而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37779086/

相关文章:

ios - 在自定义单元格中使用按钮传递信息

ios - 架构 armv7 的 undefined symbol : "_OBJC_CLASS_$_SSZipArchive"

ios - 如何制作不透明的 UIButton?

macos - swift 2.0 : Cannot invoke 'setValue' with an argument list of

ios - 为什么不能从一个 URL 获得响应?

ios - 当前用户是否在不同的设备上登录

ios - 如何使 iOS 应用程序进入挂起状态以测试后台任务行为?

ios - 如何在不破坏 Rust 工具链的情况下在 XCode 中测试 iOS 应用程序?

swift - 如何在 NSTask 退出后不阻塞地通知其终止状态?

ios - Xcode 中的 po 命令不生成输出