elp
elp

Reputation: 8131

How to speed up table row scroll?

i have a table row maded by these elements:

alt text

1 - image view (the calendar)
4 - uilabel (month, day, title, description)

on cellForRowAtIndexPath i fill labels in this way (the image is the same and is inserted by interface builder):

@try {
    newsRow = ((NewsRowController *)[tableView dequeueReusableCellWithIdentifier:@"cell"]);
    if (newsRow == nil) {
        if (IS_IPAD)
            [[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil];
        else [[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil];

        if ([tableArray count] > 0) {
            [newsRow setCellDataWithName:[tableArray objectAtIndex:indexPath.row]  
                                 andDate:[descArray objectAtIndex:indexPath.row] 
                                     day:[dayArray objectAtIndex:indexPath.row]
                                   month:[monthArray objectAtIndex:indexPath.row]];
        }
    }       
}
@catch (NSException * e) {
    NSLog(@"fail.");
}
return newsRow;

Now, tableArray, descArray, dayArray, monthArray are NSMutableArray populated on viewDidLoad.

Why on iPhone device (my test is with 3G) is too slow to scroll up/down?
What i need to remove to speed up table?
This is all of my code, but i don't able to find a better solution...

EDIT:
alt text
I don't able to set identifier... i don't see it...
and my News Row Controller is an:

@interface NewsRowController : UITableViewCell

Any idea from the world of iphonist??? :)

thanks,
A

Upvotes: 1

Views: 332

Answers (1)

Matthias Bauch
Matthias Bauch

Reputation: 90117

is the reuseidentifier of your tableviewcell in the nib file correct? (you can find it in the attribute inspector)

I doubt it, because if it would be "cell" you would ask why your cells don't update.


Edit: Check again in interface builder if the identifier is exactly the same as in your code. Interface Builder Table View Cell Identifier

and then change your code like this:

if (newsRow == nil) {
    if (IS_IPAD)
        [[NSBundle mainBundle] loadNibNamed:@"NewsRow_ipad" owner:self options:nil];
    else 
        [[NSBundle mainBundle] loadNibNamed:@"NewsRow" owner:self options:nil];
}
else {
    NSLog(@"Dequeue success");
}
// no matter if there was a successful dequeue or not, you have a valid cell at this point
if ([tableArray count] > 0) {
    [newsRow setCellDataWithName:[tableArray objectAtIndex:indexPath.row]  
                         andDate:[descArray objectAtIndex:indexPath.row] 
                             day:[dayArray objectAtIndex:indexPath.row]
                           month:[monthArray objectAtIndex:indexPath.row]];
}

see if you can see the Dequeue success logmessage


EDIT2

are you sure you have added a Table View Cell and not a UIView to your Nib?
I've never tried but for me it sounds possible that you can have an UIView in a nib which gets "promoted" to an TableViewCell which is added to an tableview.

My best attempt to check for this is the icon of the cell It should look like this: cell icon

Upvotes: 5

Related Questions