ios - Table cells appear empty -
i'm having problem populating tables. created custom view , in view created tableview. code uiview
subclass given below . table appears , delegates called.
24 cells created per delegate , appear text or other cell contents don't appear. i'm not able change cell property including cell background color.
- (id)initwithframe:(cgrect)frame andcellheight:(cgfloat)cellh{ self = [super initwithframe:frame]; if(self){ [self inittimearray]; [self inittable]; } return self; } - (void) inittable{ timeline = [[uitableview alloc]initwithframe:cgrectmake(0, 0, self.frame.size.width,self.frame.size.height )]; timeline.backgroundcolor = [ uicolor clearcolor]; timeline.separatorstyle = uitableviewcellseparatorstylenone; timeline.rowheight = cellheight; timeline.delegate =self; timeline.datasource = self; [self addsubview:timeline]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath{ static nsstring *simpletableidentifier = @"timecell"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:nil]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:simpletableidentifier]; [cell setbackgroundcolor:[uicolor bluecolor]]; } uiview *lineview = [[uiview alloc]initwithframe:cgrectmake(0, 0, 28, 2)]; [lineview setbackgroundcolor:[uicolor graycolor]]; // [cell.contentview addsubview:lineview]; uilabel *time = [[uilabel alloc]initwithframe:cgrectmake(0, 10, 40 , 40)]; time.text = @"test text"; time.textcolor = [ uicolor redcolor]; cell.textlabel.text = @"another test text"; [time setfont:[uifont systemfontofsize:14]]; [cell.contentview addsubview:time]; return cell; } -(void) inittimearray { timearray = [nsarray arraywithobjects:@"12 pm", @"11 pm" , @"10 pm", @"9 pm", @"8 pm" , @"7 pm" , @"6 pm", @"5 pm", @"4 pm" , @"3 pm" , @"2 pm", @"1 pm", @"12 pm", @"11 am" , @"10 am", @"9 am", @"8 am" , @"7 am" , @"6 am", @"5 am", @"4 am" , @"3 am", @"2 am", @"1 am" , @"12 am", nil]; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section{ return 24; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview{ return 1; }
Comments
Post a Comment