Re: iPhone: load cell from XIB slows down tableview?
Re: iPhone: load cell from XIB slows down tableview?
- Subject: Re: iPhone: load cell from XIB slows down tableview?
- From: Damien Cooke <email@hidden>
- Date: Mon, 4 Jan 2010 23:50:42 +1030
John,
I had a similar issue. For me the problem turned out to be that the
reusableId was not being set as it was imported from the nib. Thus the
call dequeue one was always retuning nil. I solved this by building
the cell by hand and calling the correct init method so the reusableid
was being set and all works well now. Let me know if there is a better
solution.
Regards
Damien
Sent from my iPhone 3GS
On 04/01/2010, at 3:33 PM, John Michael Zorko <email@hidden> wrote:
Hello, all ...
I'm trying to determine why my tableviews scroll so jerkily on
non-3GS devices. The datasource only has perhaps 170 records, so I
think it may have something to do with how i'm instantiating the
cells in -tableView:cellForRowAtIndexPath. In other apps i've done,
I create the view for the cell programmatically, and alloc / init
the cell if I can't dequeue it. However, in this app, I have the
cell's view loaded from a XIB. Is there a better way of defining my
cell's view with IB that still results in a performant tableview?
- (UITableViewCell *)tableView:(UITableView *)tableViewIn
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"mycellID";
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication
sharedApplication] delegate];
LogDailyCell *cell = (LogDailyCell *)[tableViewIn
dequeueReusableCellWithIdentifier:cellID];
if (nil == cell)
{
NSArray *nib = [[NSBundle mainBundle]
loadNibNamed:@"LogDailyCell"
owner:self
options:nil];
for (id oneObject in nib)
{
if ([oneObject isKindOfClass:[LogDailyCell class]])
{
cell = (LogDailyCell *)oneObject;
break;
}
}
}
MyObject *act = nil;
switch(indexPath.section)
{
case 0:
act = [appDelegate array1ItemAtIndex:indexPath.row];
cell.type = 2;
break;
case 1:
act = [appDelegate array2ItemAtIndex:indexPath.row];
cell.type = 3;
break;
case 2:
act = [appDelegate array3ItemAtIndex:indexPath.row];
cell.type = 4;
break;
case 3:
act = [appDelegate array4ItemAtIndex:indexPath.row];
cell.type = 5;
break;
}
cell.name.text = act.name;
cell.label1.text = [NSString stringWithFormat:@"%i",
act.anNSString];
cell.field1.text = @"";
cell.field2.text = @"";
cell.ident = indexPath.row;
[cell.deleteButton removeFromSuperview];
return cell;
}
Regards,
John
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden