I need to have some sort of scrollview which is a grid 3 x n where n is determined by the result of a call to a URL. I was wondering whether a Tableview with custom tableviewcells or a scrollview with my custom views would best serve this purpose? Any pros and cons or links to help 开发者_高级运维would be great. Many thanks Jules
The choice really depends on how you want them to scroll. If the 3 columns are to be linked, and scrolled all at once, then I definitely vote for custom UITableViewCells.
- This reduces memory usage. The iOS UITableView implementation only keeps the currently visible cells in memory, so if you have 500 rows, you don't have all 500 views in memory. Obviously you still have the data you're filling them with in memory, but there's no real way around that unless you're retrieving the results in chunks
- Implementing custom cells is almost trivial.
- No need to resize the view itself, the table handles the scrolling and sizing itself
Whereas for the scrollview approach:
- You will need to keep all of the views with your data in them in memory, unless you implement some kind of management system for it
- You have to add each view (that would basically be a custom tableviewcell) manually
- Depending on how your retrieval is, you will need to resize the scrollview's content size each time you add a new view
I presently have released an app myself that has several tableviews with custom cells to display data retrieved from a webservice. This implementation was very easy, and very intuitive to end users
精彩评论