开发者

How do I make a UITableView that remembers it's row names

开发者 https://www.devze.com 2022-12-21 12:43 出处:网络
I have a UITableView that I am allocating multiple times during the lifetime of my app, I wa开发者_如何学编程nt the names of the rows to stay in scope. What is the most memory efficient way of doing t

I have a UITableView that I am allocating multiple times during the lifetime of my app, I wa开发者_如何学编程nt the names of the rows to stay in scope. What is the most memory efficient way of doing this.


UITableView is not intended to "remember" anything (if you reuse UITableViewCells properly it may not even "remember" what it displayed in a cell that just hid during scrolling) - it "asks" its DataSource what data to display in a cell for a certain index path. So you must have separate class (data source) which is responsible for "remembering" row names and providing those names for table view to display.

To persist datasource while application works you can implement it as a singleton class or make a member of some other class (e.g. your application delegate).

0

精彩评论

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

关注公众号