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; …Run Code Online (Sandbox Code Playgroud)