不要在UITableView中重复使用单元格 [英] Don't reuse cell in UITableView

查看:67
本文介绍了不要在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'

这篇关于不要在UITableView中重复使用单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆