开发者

if I have 6 sections with 2 displayed on the screen, and I scroll down.. Do I effectively have 2 sections (reusability) or 6 sections?

This may be a very basic question. But I am finding it confusing with my tableView acting weird when I scroll up and down.

So UITableViewCells are Reusable !! So each row in my tableViewCell is reusable, and so, if I scroll down, I tend to use the same cells for different purposes (as programmed). My assumption is that 'a cell is a row'

Are sections reusable as well ?

So if I have 6 sections with 2 displayed on the screen at the moment, and I scroll down.... Do I effe开发者_如何学运维ctively have 2 sections being reused thrice or do I have 6 sections ?


A Section is just visual appearance of groups of UITableViewCells in a UITableView. It is not a object or something that one can reuse.

Another reason why sections can not be made reusable is that, its rare that two sections contain same number of rows of same kinds of cells.

The only reusable elements in a table view are UITableViewCells.


As I understand it a section is not an object where a cell is. Therefore you do not need to give a section any memory as you do when you allocate a cell so do not need to recycle the sections in order to save memory. They are just indices for which section you are in. So "no" I think is the answer.

Perhaps if you posted your code we could be more help.

Martin


Cells are rows, yes. Sections themselves aren't reusable, but you can dictate which kind of cell gets reused for each section using the reuseIdentifier. That may give you the behavior you're looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜