Mysterious problem with UITableView
I am new to iPhone development. I am working on a table view (a subclass of UITableView by default) that contains complex custom cells with multiple subzones and controls. The scrolling is not very smooth, but for now I'll just leave that.
The question is, when I view the table view with quick clicks, the table sometimes stops scrolling unexpectedly and the scroll indicator does not disappear and I have to swipe across the screen again to do the scrolling.
If the table contains very few rows, say 5 or 6, it never gets stuck. The custom class I used from the example given here: http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/
Can anyone provide a hint or solution to this problem? Thanks in advance.
source to share
- Table cells are only created when needed, that is, when they appear, and they are usually unloaded and released when they go out of sight.
- Paste the code
NSLog( @"Cell loading" );
into the cell creation code and check the console to see how it scrolls. - Are you using caching? The docs demonstrate how you can cache table cells for better performance. What else do you do when you create
table cells
? If there are any performance slowdowns, you probably shouldn't be doing it when creating cells. - What I do is that I generate all my content before the table is loaded, and when the cells are created, all the content is simply put into the view.
- Any drawing view will dramatically decrease performance, especially if you are using transparency.
source to share
I would look at your cellForRowAtIndexPath method - for a couple of potential problems.
Unless you are using cell reuse that will slow things down a lot, and if you are redistributing or reinitializing your custom cells in the delegate method cellForRowAtIndexPath, which can cause big performance issues.
If you post your code for this method, we can give you some advice on what might trigger it.
source to share