Tong Liu
Tong Liu

Reputation: 455

Mysterious UITableView stuck problem

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.

Upvotes: 3

Views: 3144

Answers (3)

Bjorn
Bjorn

Reputation: 71880

  1. 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.
  2. Put in an NSLog( @"Cell loading" ); in your cell creation code and check the console to see this happen as you scroll.
  3. 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.
  4. 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.
  5. Any kind of drawing will drastically reduce performance especially if you're using transparency.

Upvotes: 1

Cesar
Cesar

Reputation: 11

For posterity, and only valid if you are using Unity-iphone: this problem was driving me insane and I fixed it with the suggestion in this post:

http://forum.unity3d.com/threads/113815-quot-Sticky-quot-scrolling-in-UITableView-and-UIScrollView-when-interfacing-Unity-and-Obj-C

Changing the preprocessor flag to

#define USE_DISPLAY_LINK_IF_AVAILABLE 0

gave the issue a happy ending.

Upvotes: 1

paulthenerd
paulthenerd

Reputation: 9507

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.

Upvotes: 0

Related Questions