zho*_*lei 3 tableview ios swift
tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell运行几次后我收到错误.
这是事情:我创建了一个teacherArray包含用于单元格的数据,它肯定包含我需要的东西.
我使用故事板来定制单元格和tableview.我已经检查了单元格的标识符是否已设置,我还为表格视图和标识检查器中的单元格定制了类.
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return teacherArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("SearchCell", forIndexPath:indexPath) as SearchCell
cell.nameLabel.text = teacherArray[indexPath.row].name
cell.schoolLabel.text = teacherArray[indexPath.row].school
cell.experienceLabel.text = teacherArray[indexPath.row].experience
cell.courseLabel.text = teacherArray[indexPath.row].course
println(indexPath.row)
println(cell)
return cell
}
Run Code Online (Sandbox Code Playgroud)
我已经跟踪了这个方法,它是在这个控制台输出之后:
6
PAL.SearchCell: 0x7bf32310; baseClass = UITableViewCell; frame = (0 450; 320 75); autoresize = W; layer = <CALayer: 0x7bf322e0>
Run Code Online (Sandbox Code Playgroud)
...我收到此错误消息:
2015-04-26 22:27:54.880 PAL[65213:6357947]*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-3318.93/UITableView.m:7344
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么.任何的想法?
小智 7
试试这个:
add UITableViewDataSource, UITableViewDelegate:
class HDMainHotBoleCtr: UIViewController, UITableViewDataSource, UITableViewDelegate {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2667 次 |
| 最近记录: |