我有一个TableViewController和静态单元格;我试图给其中一个单元格一个类并用dequeueReusableCellWithIdentifier
检测它。我用..
class MyCell: UITableViewCell {
}
但是当我使用它时它会崩溃
override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
let cell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath) as! MyCell
}
unable to dequeue a cell with identifier MyCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
答案 0 :(得分:2)
问题是你正试图在
中消除细胞override func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
}
永远不要在tableView:cellForRowAtIndexPath:
如果你想要一个单元格的实例,你可以使用
tableView.cellForRowAtIndexPath(indexPath)
这将解决问题。