I am wondering what the best practice is in iOS development when it comes to building the UI for a particular screen. Since it is possible to create custom cells for tableviews you can use a tableview to create just about any layout/UI that you could want. Which leads me to my question:
In general when creating a screen on an iPhone application which will have more content than can fit on a single screen, is it better to use a scrollview and load your custom views into the scrollview, or to create a tableview and have your custom views instead be custom tableview cells?
In the end it seems like you can achieve the exact same visual result but what is best practice. It is hard for me to tell on apps that I have downloaded if a particular scrollable screen was built using a tableview or a scrollview.
In HTML you should only use the element for displaying tabular data, not for layout and style purposes. Is it the same case in iOS? Is it poor practice to use tableviews for layout purposes (eg, a home screen of an app which lists buttons to go to other sections of an app)?
Cheers in advance.
If you have lots of content to scroll through, a
UITableViewmight help you with keeping memory usage down.When a cell scrolls out of sight, it gets removed from the view and kept around by the
UITableViewfor later use (via-dequeueReusableCellWithIdentifier:). If you run low on memory then I believe that those invisible views (UITableViewCells) will get released. This basically means that your app will only keep views in memory that are actually visible. More will be cached, but can be purged any time if needed.If you display a lot of data, and just add it all to a
UIScrollViewit will potentially use much more memory than if you used aUITableView. You might have to implement a similar mechanism to whatUITableViewdoes to remove (and potentially release) invisible views.So, you can basically achieve the same effect, but a
UITableViewdoes a lot of that work for you already.If you display lots of data (probably more than about two screens full) I’d lean towards using a
UITableView.