开发者

Custom uitableviewcell or scrollview with customviews?

开发者 https://www.devze.com 2023-03-09 16:15 出处:网络
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

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.

  1. 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
  2. Implementing custom cells is almost trivial.
  3. No need to resize the view itself, the table handles the scrolling and sizing itself

Whereas for the scrollview approach:

  1. 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
  2. You have to add each view (that would basically be a custom tableviewcell) manually
  3. 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

0

精彩评论

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