简体   繁体   中英

Objective-c Removing a reuseIdentifier from a UITableViewCell

I have a custom UITableViewCell that has data that I get from the server. I set the reuseIdentifier of the cell when the data comes in. Everything works fine, until I do a pull down to refresh and get new/updated data. The identifier from the server is the same, but the data may be different (which is an expected result in this case). When this happens I need to re-create the cells, and keep the same reuseIdentifier. I know that not setting the reuseIdentifier is one way around this, but that's a very bad idea, that hurts performance.

I've looked at plenty of question here involving reuseIdentifier's, but none of them seam to answer my question.

Thank you for any insight you have!

There's no need to clear the reuseIdentifier. Simply reload the table view after setting up your new data. All visible cells will be reloaded. Using the same reuseIdentifier is fine. As long as your cellForRowAtIndexPath method is using the new data to populate each cell, you will get the desired results.

Update - The comment by mkral is a good clarification. The reuseIdentifier represents the type of cell, not the data. So the reuseIdentifier should have nothing to do at all with the identifier from the server unless the server's identifier affects the type of cells being shown.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM