views:

77

answers:

1

I have an UITableView showing custom view cells that I've designed in interface builder. It has quite many buttons and labels and a gradient background, which makes the scrolling performance sloppy, it "lags" every time a new cell loads. I've read the guide from the guy who created Tweetie about fast scrolling, and it says it's best to draw everything manually.

Is there any other way to do this? I want to use my .xib file since it's quite tedious work to draw all those components manually.

This is how the cellForRowAtIndexPath: method is implemented:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"ThreadsViewCell";

    ThreadViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil){       
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ThreadViewCell" owner:nil options:nil];

        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[ThreadViewCell class]])
            {
                cell = (ThreadViewCell *)currentObject;
                break;
            }
        }
    }
+1  A: 

Complex view hierarchies and alpha blending will always kill your scrolling performance.

You need to either flatten/simplify the view hierarchy, or start working on your CoreGraphics skills.

If you're interested in seeing how much blending you have going on, run (on a device) the "Core Animation" mode in instruments and check the "Color Blended Layers" check box. You want to see as much green as possible, the darker the red, the worse your blending.

Jerry Jones
Thanks! I'll check that out.
Accatyyc