【发布时间】:2013-11-24 14:30:50
【问题描述】:
我在我的应用程序中添加了一个新的 TableView。我将单元格类型更改为静态并将一些标签拖到单元格中。现在我想以编程方式访问单元格。例如:第 3 节中的单元格 4 应该打开 google.com 的 safari。
我创建了一个新的 UITableViewController 类。然后我将节数更改为 3,并在 numberofcellsinsection 方法中添加了 switch/case 语句。
如果我运行应用程序并打开表格视图,应用程序就会崩溃。有人可以帮助我设置 TableView 吗?
谢谢!
编辑
这是日志
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
*** First throw call stack:
【问题讨论】:
-
请发布崩溃日志。
-
@XCodeMonkey 编辑了它
-
要分别访问不同的单元格,您可能需要为此使用不同的标识符。尝试在单元格中使用 if 或 switch 语句来访问不同的单元格。查看此链接以更好地了解它是如何完成的...stackoverflow.com/questions/14303832/…
-
我没有任何标识符,因为我使用的是静态单元格。我是否必须更改 cellForRowAtIndexPath 方法中的某些内容?
-
当您使用静态单元格时,您不应该实现任何数据源方法。您应该阅读“iOS 表视图编程指南”中的“使用数据填充静态表视图”部分。
标签: ios iphone objective-c uitableview