ingenspor
ingenspor

Reputation: 932

Scroll lag in UITableView cells with large images

I've created a prototype UITableViewCell and populated it with dictionaries containing strings with image paths and label text for the cell. I'm using the same image size for the UITableViewCell's UIImageView as in lager image views in my app, and some of the images are pretty large.. Like ie 300w x 800h and 300 kb size. So each cell is loading content about 500 kb totally. So when I run the app, on the first scroll down the UITableView (when the cells are created), i experience a lag in the scrolling.

If I leave it like this, will it go through the App Store review or is it likely to be rejected for this? Heard of any cases?

I know I can make some smaller images for UITableViewCell. Then, what is the preferred pixle dimentions for the UIImageView (older iphone and retina)? (Or is there maybe a maximun kb loading limit for UITableViewCell?)

If you're going to say 44 and 88 points, research is telling me this is the default height of the UITableViewCell itself, and got nothing to do with UIImageView dimentions, or kb limit if there is one..

And last: Is there other (apple approved ways) of avoiding the lag? Like creating the cells before the scroll begins, or something?

Upvotes: 0

Views: 1429

Answers (1)

Suresh Varma
Suresh Varma

Reputation: 9740

Try Using LazyLoading. If the images are coming from Server. That is the main issue of the lag(delay) and Since hte cell is reused So whenever you scroll It loads the image each time.

Also Since you have said that the images are very large So try converting the images to smaller size. The size of the image is not predefined to 44 or 88 or anything. We can set the size depending upon the height of the cell.

EDIT As Kristoffer Said that the images are from his main bundle and not from the server Can you please try changing in cellForRowAtIndexPath the line

static NSString *CellIdentifier = @"Cell";

with

NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d",indexPath.row,indexPath.section];

Not much sure whether it will work or not. But it will stop reusing the cell So Your cell wont reload the already loaded image in the cell.

Upvotes: 1

Related Questions