ios - Objective C: UITableView Scrolling becomes Laggy -
i have uitableview becomes laggy when during scrolling. code snippet follows:
in "cell setupcell" have few customized items added cell contentview
1 x uiimageview
3 x uilabels
3 x buttons (subclass of uicontrol)
my initial testing seems point buttons causing lag. have checks in button class
i not sure cause lag these checks seemed simple , basic operations. has advise on causes such lags?
edit: add more code
i want add scrolling smooth when first started app, became laggy , slow after scrolled table , down multiple times. code follows:
if (cell == nil) { cell = [[[customcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:placeholdercellidentifier] autorelease]; //add button uicustombutton *likebutton = [[uicustombutton alloc]init]; likebutton.tag = 7; //add comment button uicustombutton *commentbutton = [[uicustombutton alloc]init]; commentbutton.tag = 8; //add answer button uicustombutton *answerbutton = [[uicustombutton alloc]init]; answerbutton.tag = 9; [self.contentview addsubview:likebutton]; [self.contentview addsubview:commentbutton]; [self.contentview addsubview:answerbutton]; [likebutton release]; [commentbutton release]; [answerbutton release]; } //set button uicustombutton *thislikebutton = (uicustombutton *)[self.contentview viewwithtag:7]; [thislikebutton setbuttonwithanswer:self.answerforcell buttontype:@"like" navcon:self.navcon andframe:cgrectmake(cell_text_left_margin, totalcommentlabelheight + cell_spacing*4, 45, cell_button_height)]; thislikebutton.imageview.image = [uiimage imagenamed:@"heart.png"]; //set comment button uicustombutton *thiscommentbutton = (uicustombutton *)[self.contentview viewwithtag:8]; [thiscommentbutton setbuttonwithanswer:self.answerforcell buttontype:@"comment" navcon:self.navcon andframe:cgrectmake(cell_text_left_margin + 45 + 5, totalcommentlabelheight + cell_spacing*4, 80, cell_button_height)]; thiscommentbutton.imageview.image = [uiimage imagenamed:@"chat.png"]; //set answer button uicustombutton *thisanswerbutton = (uicustombutton *)[self.contentview viewwithtag:9]; [thisanswerbutton setbuttonwithanswer:self.answerforcell buttontype:@"join in" navcon:self.navcon andframe:cgrectmake(1.5*cell_text_left_margin + 45 + 5 + 80 + 5, totalcommentlabelheight + cell_spacing*4, 60, cell_button_height)]; thisanswerbutton.imageview.image = [uiimage imagenamed:@"beer-mug_white.png"];
i have checked instruments , don't seem indicate leakages part of code
can advise might cause of laggy after series of scrolling?
run in instruments, see it's spending time when scroll.
Comments
Post a Comment