0

I'm developing an iPad app on which i have a very big UITableView (about 10x screen width and height) and above of this a UIScrollView that I'm able to scroll horizontally.

In every UITableViewCell i add a various amount of UIViews. My Problem is that the scrolling performance is really bad. So i searched Google for an solution but did not find anything that was suitable for my problem.

I think the problem is that the entire screen is redrawn when a scrolling is done but i don't know how to limit this...

Can anybody provide a solution?

Thanks.

Yogesh Suthar
  • 30,424
  • 18
  • 72
  • 100
user944351
  • 1,213
  • 2
  • 19
  • 27

3 Answers3

1

You will need to maintain re usability of the cell and only load the views required in the visible area. Same as we do lazy loading of images.

Javal Nanda
  • 1,828
  • 3
  • 14
  • 26
  • can you provide some additional information to that? links or examples? thanks – user944351 May 15 '12 at 14:23
  • 1
    have a look at following example you will get idea how to implement it http://developer.apple.com/library/ios/#samplecode/ScrollViewSuite/Introduction/Intro.html – Javal Nanda May 16 '12 at 04:29
1

The simple key to improve performance is not to do time consuming task in cellForRowAtIndexpath.

You can employ many tricks to improve performance. For ex, loading your view in back ground thread.

This SO post describes various tricks.

Community
  • 1
  • 1
Vignesh
  • 10,205
  • 2
  • 35
  • 73
  • where else should i draw the views to the cells when not in the cellForRowAtIndexpath? – user944351 May 15 '12 at 14:26
  • You can load it lazily. I meant put it in a background thread.Cache it for next use. The point here is when ever you do heavy task in cellForRowAtIndexPath you are bound to face performance issues. The SO link contains many tips to improve performance . – Vignesh May 15 '12 at 14:29
1

You need to do UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; to resue the cell. What you should do is this if you haven't yet:

in your

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

method, you need:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"] autorelease];
}

Take a look at this from Apple's documentation.

Hope this helps.

Raymond Wang
  • 1,484
  • 2
  • 18
  • 33