objective c - iOS UITableViewCell adding label and image -


i trying add text label or uiimage (does not matter) in uitableviewcell. did not appear. using few views in cell. can see in code below:

    - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath     {         static nsstring *cellidentifier = @"timelinecell";         kmwtableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];          if (cell)         {             cell = [cell initwithframe:cgrectmake(13, 10, 293, 200)];              uiview *cellcontentview = [[uiview alloc] initwithframe:cgrectmake(13, 10, 293, 200)];             cellcontentview.layer.cornerradius = 5;             cellcontentview.layer.shadowoffset = cgsizemake(1, 0);             cellcontentview.layer.shadowcolor = [[uicolor blackcolor] cgcolor];             cellcontentview.layer.shadowradius = 5;             cellcontentview.layer.shadowopacity = .25;             cellcontentview.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"cellback"]];               uiview *selectedcontentview = [[uiview alloc] initwithframe:cgrectmake(13, 10, 293, 200)];             selectedcontentview.layer.cornerradius = 5;             selectedcontentview.layer.shadowoffset = cgsizemake(1, 0);             selectedcontentview.layer.shadowcolor = [[uicolor blackcolor] cgcolor];             selectedcontentview.layer.shadowradius = 5;             selectedcontentview.layer.shadowopacity = .25;             selectedcontentview.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"cellbackactive"]];               uiview *visiblecontentview = [[uiview alloc] initwithframe:cgrectmake(13, 10, 293, 200)];             visiblecontentview.layer.cornerradius = 5;             visiblecontentview.layer.shadowoffset = cgsizemake(1, 0);             visiblecontentview.layer.shadowcolor = [[uicolor blackcolor] cgcolor];             visiblecontentview.layer.shadowradius = 5;             visiblecontentview.layer.shadowopacity = .25;             visiblecontentview.backgroundcolor = [uicolor clearcolor]; //image adding here:  [ uiimageview *image = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"active.png"]];         [visiblecontentview addsubview:image];              [cellcontentview addsubview:visiblecontentview];             [selectedcontentview addsubview:visiblecontentview];              [cell setbackgroundview:cellcontentview];             [cell setselectedbackgroundview:selectedcontentview];          }          return cell;     } 

as can see using backgroundview , selectedbackgroundview , view other info clearcolor. why other elements not display in visibleview?

update:

i using subclass because need change frame size of cell.

i think problem adding visiblecontentview selectedcontentview right after add cellcontentview. removes cellcontentview because view can have 1 superview @ time. visiblecontentview in selectedcontentview. if kmwtableviewcell works properly, should see missing components when cell selected.


Comments