2016-02-27 74 views
-3

編輯:
我無法在AppDelegate類中找到該方法。它在哪裏?我只做一個嗎?Swift xcode項目錯誤。無法從表中檢索單元

我的項目是建立一個應用程序,其中包含一個窗口中的動物名稱列表,然後當您單擊一行時,您將被轉移到另一個窗口並顯示動物的描述。

當它崩潰我得到這個消息(見截圖):

enter image description here

這裏是我的所有的故事板,與鏈接,和我所有的類(和代碼在其中)

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

導航欄在右側的Connections Inspector(箭頭標籤)中沒有任何內容。

+0

協議方法請發表您的'cellForRowAtIndexPath'代碼,這就是問題的所在。 – paulvs

+0

我無法在AppDelegate類中找到該方法。它在哪裏?我只做一個嗎? – David

回答

0

該錯誤似乎是因爲你從你的返回零位cellForRowAtIndexPath數據源委託方法。

參見:https://stackoverflow.com/a/34250654/1305067

+0

我無法在AppDelegate類中找到名爲「cellForRowAtIndexPath」的方法,我應該只做一個? – David

+0

是的,這是您需要實施的表視圖才能工作的必需方法。我建議你看一下簡單的表格視圖教程,例如(http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/),它解釋瞭如何獲得一個基本的表格查看並運行。 – paulvs

0

當你忘記了UITableViewDataSource的UITableViewDelegate協議添加到ViewController聲明。

import UIKit 

class DetailViewController: UIViewController, UITableViewDelegate, UITableViewDataSource 

您只需複製並粘貼上面的代碼即可解決問題。

但是你要確保你要實現你的DetailViewController