Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Hi,

When I segue to a table view controller that contains the following dynamic table view cell

Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    
    // Configure the cell...
    Content *tc = [totalContent objectAtIndex:indexPath.row];
    cell.imageView.image = tc.Image1;
    cell.textLabel.text = tc.QuestionName;
    cell.detailTextLabel.text = tc.QuestionSubName;
    
    return cell;
}

the 29 rows that load appear with a preview image, positioned to the left of my text. By tapping each row, the image object is passed to the next view, using a prepareforsegue method.

On first load into the table view, the performance stutters and freezes and the user scrolls down. Once the user reaches the bottom of the table view, and all the preview images have loaded into memory, the performance stabilises and scrolling is smooth.

I'm trying to find a way to improve performance. Should I save these images to file, then read them from file in the above method? Can someone help me understand how I can improve performance of my table view in iOS please?

Thanks
Rob
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Async image loading tableview, or lazy loading tableview, maybe that helps you a bit without giving you the exact code :) (hint: google those words).

Ha, I actually appreciate this. Self-learning things like this is a big effort and it's easy to lose your way. Thanks.
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
The lazy table view method is interesting, but the apple music app doesn't perform that way. In album view, the images are instantly displayed. How does apple pull this off?
 

xStep

macrumors 68020
Jan 28, 2003
2,031
143
Less lost in L.A.
Magic doesn't really exist. ;)

Perhaps it only appears to load instantly. Perhaps the thumbnails are so small that they load very fast. Perhaps they are using larger images made up of smaller thumbnails, allowing them to load a group. None of this excludes that Apple is using Async. They likely are in some way.

There is at least one WWDC video that discusses this tactic. I'd be guessing to say it is Practical Drawing for iOS Developers, or UITableView Changes, Tips & Tricks from WWDC 2011, or Advanced Performance Optimization on iPhone OS, Part 1 or Part 2, or Performance Optimization on iPhone OS, or Mastering Table Views from WWDC 2010. That last one sounds like a good place to start.

Sorry I couldn't be more helpful on the video or other direction. I just remember watching these and being impressed with with samples as they demonstrated the techniques.
 
Last edited:

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
I still haven't figured this out. However, someone posted on stack forum, that it might be a good idea to have a separate array of my images already scaled to the appropriate size - and have them load into the tablleviewcell image.

I'm going to try this. Does anyone know the dimensions of the image in a table view cell? It's hard to find.

The inspector in Xcode shows the dimensions of the table view cell to be 44x22. I've seen several posts on this and all say different values. Some say 88x88 pixels, but the image doesn't appear square in the table view cell, so this must be wrong.
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
I images used with dimensions 88x59 pixels at 31ppi, and now it's all working fine.

I learned about multi-threading basics from the book 'beginning IOS 5 Developerment' by Dave, Mark and Jeff. It's a really good book. My app is pretty small and multithreading manipulations is cool, but inappropriate for what I need right now.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.