0
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
}
}
}
我得到的錯誤是:終止應用程序由於未捕獲的異常 'NSInternalInconsistencyException' 錯誤
終止應用程序由於未捕獲的異常 'NSInternalInconsistencyException',原因是:「 - [UITableViewController中 的loadView]實例化視圖控制器從標題爲「Main」的標識符 「UIViewController-tCJ-qt-q4b」,但未獲得 UITableView。
任何人都知道我可以解決這個問題嗎?
我刪除了TableViewDelegate子類,並試圖將commentAction按鈕連接到tableview,我仍然收到錯誤。 – Chris
您的評論聽起來不像您提出的建議。我並不感到驚訝,你仍然得到錯誤。 –