拥有一个UITableViewController
并使用:
override func tableView(tableView: UITableView, cellForRowAtIndexPath
indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("reuseIdentifier", forIndexPath: indexPath) as! UITableViewCell
return cell
}
使用 dequeueReusableCellWithIdentifier:forIndexPath:'' 而不是
dequeueReusableCellWithIdentifier`` 我如何确定一个单元格是新单元格还是重复使用的单元格?
最佳答案
创建您自己的自定义单元类以用于重用标识符。然后,在该单元格内,实现 awakeFromNib
并对单元格进行更改。当您的单元格从其 NIB 文件加载时,这只会被调用一次。
可以在 prepareForReuse
中进行重用单元格时需要进行的任何其他更改。
关于ios - 使用 dequeueReusableCellWithIdentifier :forIndexPath:? 时的新单元格或现有单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29845151/