不要在UITableView中重复使用单元格

问题描述:

let cell = tableView.dequeueReusableCellWithIdentifier("cellReuseIdentifier", forIndexPath: indexPath) as! CustomTableViewCell

创建单元后,我不想重复使用这些单元, 我希望它在内存中可用.

I don't want to reuse the cells once the cell is created, I want it to be available in memory.

这是您的决定,但这是 非常糟糕 的主意.除非您的tableView中的单元格少于10个,并且您100%确定不会有更多的单元格.否则,应用程序会因内存压力而很快崩溃.

It's your decision of course, but it's a very bad idea. Unless you have less than 10 cells in your tableView and you are 100% sure there will be no more cells. Otherwise the app will crash on memory pressure pretty fast.

请不要dequeue个单元格.每次创建新的内容:

Just don't dequeue cells. Create new each time:

let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "CellReuseIdentifier")

不推荐,但毕竟是您的决定.

Not recommended, but it's your decision after all.

关于最新版本的说明:

A note about most recent swift versions:

' UITableViewCellStyle '已重命名为' UITableViewCell.CellStyle '

'UITableViewCellStyle' has been renamed to 'UITableViewCell.CellStyle'