ios - Objective C: How to implement ABTableViewCell? -
i facing serious scrolling performance issues uitableview. have following subviews in custom cell
- 1 x uiimageview
- 2 x uilabel
- 3 x uibuttons
i read on net having multiple subviews in custom cell have serious implications scrolling performance. found abtableviewcell not sure how go porting current code on it.
snippet of current code
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring* placeholdercellidentifier = @"placeholdercell"; int row = [indexpath row]; someclass *thisclass = [self.someclassarray objectatindex:row]; customcell* cell = (customcell*)[tableview dequeuereusablecellwithidentifier:placeholdercellidentifier]; if (cell == nil) { cell = [[[customcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:placeholdercellidentifier] autorelease]; //set avatar imageview uiimageview *avatarview = [[uiimageview alloc]initwithframe:cgrectmake(5, cell_spacing,cell_avatar_width, cell_avatar_height)]; avatarview.tag = 1; //set text label uilabel *textlabel = [[uilabel alloc]initwithframe:cgrectzero]; textlabel.font = [uifont fontwithname:@"helvetica-bold" size:13.0]; [textlabel setlinebreakmode:uilinebreakmodewordwrap]; textlabel.numberoflines = 0; textlabel.tag = 2; //add button1 uicustombutton *button = [[uicustombutton alloc]init]; button.tag = 3; [self.contentview addsubview:avatarview]; [self.contentview addsubview:textlabel]; [self.contentview addsubview:button]; } //set avatar imageview uiimageview *thisavatarview = (uiimageview *)[self.contentview viewwithtag:1]; thisavatarview.image = self.dataforcell.user.avatar; //set data text label nsstring *text = [nsstring stringwithformat:@"%@",self.dataforcell.text]; cgfloat answerlabelheight = [customcell getheightoflabel:self.dataforcell oftype:@"xxx"]; uilabel *thistextlabel = (uilabel*)[self.contentview viewwithtag:2]; [thistextlabel setframe:cgrectmake(cell_text_left_margin, cell_spacing+cell_usernamelabel_height+questionlabelheight,cell_content_width - cell_text_left_margin*1.5, answerlabelheight)]; thistextlabel.text = somedata; //set data button uicustombutton *thisbutton = (uicustombutton *)[self.contentview viewwithtag:3]; [thisbutton setbuttonwithanswer:self.dataforcell buttontype:@"like" navcon:self.navcon andframe:cgrectmake(cell_text_left_margin, totalcommentlabelheight + cell_spacing*4, 45, cell_button_height)]; thislikebutton.imageview.image = [uiimage imagenamed:@"xxxx.png"]; }
sorry long code, can guide me along on how can start use abtableviewcell implementation?
Comments
Post a Comment