user944351
user944351

Reputation: 1213

UITableView/UIScrollView scroll optimization/performance

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.

Upvotes: 0

Views: 2046

Answers (3)

Raymond Wang
Raymond Wang

Reputation: 1484

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.

Upvotes: 1

Vignesh
Vignesh

Reputation: 10251

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.

Upvotes: 1

Javal Nanda
Javal Nanda

Reputation: 1838

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.

Upvotes: 1

Related Questions