ios - My custom uitableviewcell is very to scroll in iOS7 -
i have custom uitableviewcell made nib file , contain large imageview ( use sdwebimage) , ohattributedlabel , 5-6 uilabel
the scroll normal , rather quick in ios6 in ios7 , turns out slow , lagging.
i tried remove elements in nib file , notice slow scroll when having either large imageview (sdwebimage) or ohattributedlabel
are there ways can improve scrolling performance ? in ios6 didn't expect have problem before ( use iphone5 testing)
-(void)viewdidload { [super viewdidload]; //register nib here customitemcell [self.tableview registernib:[uinib nibwithnibname:@"customitemcell" bundle:nil] forcellreuseidentifier:@"customitemcell"]; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"customitemcell"; customitemcell *cell = (customitemcell *)[tableview dequeuereusablecellwithidentifier:squakcellidentifier forindexpath:indexpath]; customitem *item = [itemsarray objectatindex:[indexpath row]]; nsmutableattributedstring *attrstr = [[nsmutableattributedstring alloc] initwithstring:[nsstring stringwithformat:@"%@",[item post] ]]; [attrstr setfontname:@"helvetica" size:14]; // cell.postlabel ohatrributedlabel cell.postlabel.delegate = self; cell.postlabel.attributedtext = attrstr; cell.postlabel.text = [item post] ; //configurehashtage ask ohattributedlabel make hashtag link [cell configurehashtaglabel]; if([item hasimageurlstring]){ [cell.postimageview sethidden:no]; cgfloat yposition = cell.thumbnailview.frame.origin.y + cell.thumbnailview.frame.size.height+15; nsdictionary *attributes = @{nsfontattributename: [uifont fontwithname:@"helvetica" size:14]}; cgrect framesize = [item.post boundingrectwithsize:cgsizemake(220, 2000) options:nsstringdrawinguseslinefragmentorigin attributes:attributes context:nil]; yposition = max(yposition,cell.postlabel.frame.origin.y+framesize.size.height+20); [cell.postimageview setimagewithurl:[nsurl urlwithstring:[item postimageurlstring]] placeholderimage:[uiimage imagenamed:@"image_placeholder.png"] ]; cgrect imageframe = cgrectmake(10 ,yposition, 300, 200); [cell.postimageview setframe:imageframe]; [cell.postimageview setclipstobounds:yes]; cell.postimageview.userinteractionenabled = yes; [cell.postimageview setupimageviewerwithimageurl:[nsurl urlwithstring:[item postimageurlstring]]]; } else { [cell.postimageview sethidden:yes]; } return cell; }
i had huge performance impact on table scrolling performance on ios 7, , tracked down line of code:
[uisearchbar appearance].backgroundcolor = [uicolor whitecolor];
it turns out, line of code doesn't anyway - , put in mistake when customising of ios 7 app.
it must bug in sdk, removing line , re-running app, scroll performance resolved - scroll views in app. must have been doing on main run loop stealing cpu cycles... don't know if makes sense.
anyway... check , see if have appearance code, , comment out temporarily find killing performance.
Comments
Post a Comment