objective c - Adding extra UIlabel to each cell -


i'm trying add uilabel each cell(uitableview) i'v succeeded code in
(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath method

here's code

//add text uilabel *test = [[uilabel alloc] initwithframe:cgrectmake(250,80,50,20.0)]; test.text =  [nsstring stringwithformat: @"test"]; test.backgroundcolor = [uicolor clearcolor]; test.font=[uifont fontwithname:@"applegothic" size:20]; [cell addsubview:test]; 

however figured if this, can't add different text each cell, instead, ends same text in cells. can tell me how that?
oh , problem if this, "test" displayed in every cell except first one.

have @ tutorial "uitableview – adding subviews cell’s content view".

try this

- (uitableviewcell *) getcellcontentview:(nsstring *)cellidentifier {      cgrect cellframe = cgrectmake(0, 0, 320, 65);     cgrect label1frame = cgrectmake(17,5,250,18);        uilabel *lbltemp;      uitableviewcell *cell = [[[uitableviewcell alloc] initwithframe:cellframe reuseidentifier:cellidentifier] autorelease];       lbltemp = [[uilabel alloc] initwithframe:label1frame];     [lbltemp setfont:[uifont fontwithname:@"arial-boldmt" size:15]];     lbltemp.tag = 1;     lbltemp.backgroundcolor=[uicolor clearcolor];     lbltemp.numberoflines=0;     [cell.contentview addsubview:lbltemp];           return cell;  // forgot   } 

in cellforrowatindexpath

{     if(cell == nil)             cell = [self getcellcontentview:cellidentifier];      uilabel *lbltemp1 = (uilabel *)[cell viewwithtag:1];       lbltemp1.text =[namearray objectatindex:value+indexpath.row];           return cell; } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -