0

I have a page controller which consists of five table views. When swiping between these table views, there is a short lag. Is this normal or could it be caused by some bad code?

I have uploaded a short video demonstrating the issue.

[Video] UITableView with UIPageController causes a lag

EDIT: It is as if it helps removing cell.detailTextLabel.text would this make sense?

This is where I set the detail label:

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat: @"'kl.' HH:mm"];
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
[dateFormat setTimeZone:gmt];
NSString *dateFormatted = [dateFormat stringFromDate:[thisEntry objectForKey:@"date"]];

if(![[thisEntry objectForKey:@"weekDay"] isEqualToString:@"Ikke programsat"]) {
   cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@", [thisEntry objectForKey:@"scene"], dateFormatted];
}

[dateFormat release];
simonbs
  • 7,932
  • 13
  • 69
  • 115

1 Answers1

1

I would guess the issue most likely has to do with the image on the top of each page. The table in each page seems to only contain lightweight cells that contain only text. So, each table should render fairly quickly. It's the image on top that may be taking some time to render. Whenever I encounter lag in any of my apps, the first thing I look at are graphical assets. Images can take some time to render, depending on the size and resolution of the image. If it is the image, then you need to consider the possibility of using some caching. The documentation on UIImage and UIImageView contains some helpful information.

Also, I would suggest you run some tests using Shark in order to pin down exactly what part of your code is causing the performance hit. It might not be the image at all but rather some piece of code that is querying for a piece of data that it is having to wait on for some reason.

Hope this helped. Good Luck.

Gregorius T
  • 340
  • 1
  • 3
  • I think you are right. I just tried playing with the table view and it seems that the lag is happening as the image is changed. I'll try to dig into this. Caching the images seems as a great idea though it does not seem that this is a normal approach when I search around. I have not heard about Shark but I will read up on it. You don't happen to have a simple caching example? When I search around I find a few different approaches but there aren't much info about these and I'm unsure if it is done the properly. – simonbs Mar 14 '11 at 14:05
  • It is as if it helps removing the `cell.detailTextLabel.text` part. Would this make sense? – simonbs Mar 14 '11 at 18:05