Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 16, 2012, 01:25 AM   #1
nashyo
macrumors 6502
 
Join Date: Oct 2010
Location: Bristol
UITableView performance issue

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
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Feb 16, 2012, 02:29 AM   #2
jnoxx
macrumors 65816
 
jnoxx's Avatar
 
Join Date: Dec 2010
Location: Aartselaar // Antwerp // Belgium
Async image loading tableview, or lazy loading tableview, maybe that helps you a bit without giving you the exact code (hint: google those words).
__________________

iPad Mini, iPad 4, iPad 2, iPhone 3G,4,5, iMac 24", Mac Mini Last gen, Macbook Pro Retina with Dell U2711
jnoxx is offline   0 Reply With Quote
Old Feb 16, 2012, 08:04 AM   #3
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: Bristol
Quote:
Originally Posted by jnoxx View Post
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.
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Feb 16, 2012, 12:21 PM   #4
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: 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?
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Feb 16, 2012, 01:13 PM   #5
xStep
macrumors 68000
 
Join Date: Jan 2003
Location: Lost in Minneapolis
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.
__________________
My App: CameraTime - Time lapse photography for novice and advanced users.

Last edited by xStep; Feb 16, 2012 at 01:53 PM. Reason: fixed spelling
xStep is offline   0 Reply With Quote
Old Feb 16, 2012, 01:17 PM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Plus, Apple is able to do things, via private APIs, that us mere developers are not.
__________________
dejo is offline   0 Reply With Quote
Old Feb 19, 2012, 11:51 AM   #7
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: 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.
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote
Old Feb 20, 2012, 01:32 AM   #8
nashyo
Thread Starter
macrumors 6502
 
Join Date: Oct 2010
Location: 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.
__________________
Xcode 4.5.2, SDK 6.0, OSX Mountain Lion, ARC
nashyo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
freeze, performance, tablecell, uitableview

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
5th gen AirPort Extreme external disk performance issue? toad77 Mac Peripherals 6 Aug 26, 2013 08:11 PM
Issue with disabling UITableView custom cell from indenting while in editing mode ord6 iPhone/iPad Programming 6 Mar 9, 2013 12:17 PM
rMBP external display performance issue snyder17315 MacBook Pro 5 Dec 26, 2012 09:38 PM
Motion X performance issue namethisfile Digital Video 2 Nov 29, 2012 09:41 AM
Aperture 3.3 performance issue? Prodo123 Digital Photography 0 Jun 14, 2012 05:51 PM

Forum Jump

All times are GMT -5. The time now is 03:23 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC