2016-02-27 36 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