首先,讓我說,這是一個不好的問題,所以請在這裏忍受我:D。我有一個嵌入在導航控件中的tableview,這是我的主要觀點。有一個「添加」按鈕,在那裏我可以添加一個觸發,則當「東西」,它顯示了表視圖中添加的項目,並與下面iOS Swift - UITableView didselectrowatindexdex崩潰
@IBAction func buttonAddPost_Click(sender: UIButton) {
postMgr.addPost(titleBox.text, description: descriptionBox.text, postDate: date)
self.navigationController.popToRootViewControllerAnimated(true)
}
代碼切換回主視圖控制器再次上面的代碼讓我回到主表視圖控制器就好了。
但是,當我點擊一個單元格帶我到一個更詳細的視圖,應用程序崩潰。這裏是代碼
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
let listingPage = self.storyboard.instantiateViewControllerIdentifier("listingPage") as PostListingTableViewController
self.navigationController.pushViewController(listingPage, animated: true)
}
「listingsPage」是我試圖去的新視圖控制器的故事板ID。我在其他地方多次使用了上述技術,並且工作得很好,但我不確定這裏有什麼問題。
錯誤我得到: 線程1 0 swift_dynamicCast和它突出0x1d7150:pushl%ebp的線程1:EXC_BREAKPOINT(代碼= EXC_I386_BPT) 2 Exchange.PostlistTableViewController([應用名稱] [類名])和它突出了didselectrowowatindexpath 。 。 。
請幫助...
KM
非常感謝。它應該是ListingPageViewController而不是PostListingTableController。先生+1 –