views:

371

answers:

2

Hi, I'm new to iPhone development. I'm working on a table view (default UITableView subclass) that contains complicated custom cells, with multiple subviews and controls. Scrolling is not very smooth, but I'll just leave that for now.

The question is, when I'm scrolling the table view with quick swipes, the table sometimes suddenly stops scrolling and the scroll indicator will not disappear, and I have to swipe again to make it scroll.

If the table contains very few rows, say, 5 or 6, it never stuck. The custom cell class I used is from the example provided here: http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/

Can anyone give a hint or solution to this problem? Thanks in advance.

+1  A: 

Table cells are only created when needed, that is when they come into view and they are usually unloaded and released when they go out of view. Put in an NSLog( @"Cell loading" ); in your cell creation code and check the console to see this happen as you scroll. Are you using caching? The docs demonstrate how you can cache table cells to improve performance. What else are you doing when you're creating table cells? If there's any performance slow downs you should probably not have that happen while creating cells. What I do is I generate all my content before the table loads and when cells are created all that content is simply placed into the view. Any kind of drawing will drastically reduce performance especially if you're using transparency.

apphacker
Thanks for your helpful tip, though for now I'm not going to pay much attention on performance. I think I solved the "scroller stuck" problem by using the UITableViewController template generated by XCode instead of a custom UIViewController. Have tested scrolling nonstop for several minutes and the scroller never stucked.
icerelic
A: 

I'd take a look at your cellForRowAtIndexPath method - for a couple of possible problems.

If you aren't using the cell reuse that will slow things down a lot and if you are re-allocating or re-initializing your custom cells in the cellForRowAtIndexPath delegate method that can cause big performance issues.

If you post your code for that method we can give you some hints as to what might be causing it.

paulthenerd
Maybe there's something wrong with my custom UIViewController which handles table delegate methods. Anyway I (think) I solved the problem by using the UITableViewController template generated by XCode. Thanks.
icerelic