views:

206

answers:

4

Hello,

I have a UIScrollView that I am using to simulate a UITableView like interaction because rows are a bit more complex than what UITableView has to offer. I have 4 UILables a UIImageView and a UIButton for every row. The end result is a lot of subviews.

Even with only 10 rows,the scroll view that looks fine in the simulator but has a fairly low frame rate on the iPhone 4. This is a resource consumption issue for sure.

Is there a way to optimize the redraw durring scrolling like double buffering?

If not is there another way to get customizable UITableview functionality?

thanks

+2  A: 

Does every View have 4xUILabels, a UIImageView and a UIButton?

I would create a nib file with a custom UITableViewCell (You can make those as complex as you want), then you can reuse the cells to help with your performance.

Information on how to do this is here: http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW1

DVG
If scrolling performance is an issue, you shouldn't create a Cell with multiple subviews like that. Use flat view hierarchy and customize your drawing of the cell with method such as drawString... Also, make your cell view/subviews opaque if possible. Look at some of the sample code from Apple, they also use custom drawing instead of Nib file to avoid the use of subviews.
iamj4de
+1  A: 

Hi, I think you probably want to create a custom subclass of a UITableViewCell as the UITableView will handle all the redrawing for you. In a custom UITableViewCell you can add as many subviews as you like.

Mark McFarlane
+1  A: 

Take a look at http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html.

UITableViews are subclasses of UIScrollView (or at least conform to their behavior), but you really want to let the iPhone handle the selective drawing/cell reuse for you that the UITableView provides.

Mike Krieger
A: 

You should use UITableView if it does everything you need.

However if your tableview cells are really complicated, or you want to enable paging on the scrollview, you should take a look at the PageContol sample code that Apple provides. In a nutshell, you watch for movement in scrollViewDidScroll: and load new "pages" just before they become visible. This method works very well in practice for arbitrarily long lists of pages.

prok