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/