开发者

Multiple UITableViewCell types implementation

开发者 https://www.devze.com 2023-01-25 16:31 出处:网络
I wanted to know what is the best way to implement multiple cell types. I have a app wherein there will be multiple types of table cells. What out of following 开发者_如何学Cwould be best approach:

I wanted to know what is the best way to implement multiple cell types. I have a app wherein there will be multiple types of table cells. What out of following 开发者_如何学Cwould be best approach:

1) Put all the cell types in one NIB file, tag them and then use them as needed.

2) Create different cell view classes and instantiate them as and when needed.

3) Make a generic cell controller and let server decide the type of cell to be drawn as data is being flown from server.

If there is any other approach also, please tell me.


Depending on how different the cells are, you might have a separate class for each type. You can utilize the table view's built-in cell reuse to have it cache cells of different types using different reuse identifiers.

Apple discourages loading table view cells from nibs, probably because it performs badly (i.e. results in jittery scrolling). But if you have a very complicated cell layout, it can be annoying to set it all up in code. I guess you'd just have to try it for yourself. Though I would recommend putting each different cell type into a different nib.

0

精彩评论

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

关注公众号