ios - Table View Cells showing blanks -
i've got table view cell in .xib. i've got uilabel , uiimageview in .xib.
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath object:(pfobject *)object { schoolstableviewcell *cell = (schoolstableviewcell *) [[[nsbundle mainbundle] loadnibnamed:@"schoolstableviewcell" owner:self options:nil] lastobject]; nslog(@"before: %@", cell.namelabel.text); cell.namelabel.text = [nsstring stringwithformat:@"name: %@", [object objectforkey:@"name"]]; nslog(@"after: %@", cell.namelabel.text); pffile *file = [object objectforkey:@"logo"]; [file getdatainbackgroundwithblock:^(nsdata *data, nserror *error) { cell.logoimageview.image = [uiimage imagewithdata:data]; }]; return cell; } as can see, have 2 nslog()s, printing below:
2015-07-08 20:17:26.739 o [1871:108786] before: (null) 2015-07-08 20:17:26.740 o [1871:108786] after: name: smsas that expected.
however, on simulator, can see blank cell name:. should show smsas in label, , load logo, it's not happening. can pass object next view controller when cell tapped, , can show in view controller.
this .m cell.
@implementation schoolstableviewcell - (void)awakefromnib { [super awakefromnib]; self.namelabel = [[uilabel alloc] init]; self.logoimageview = [[uiimageview alloc] init]; [self.contentview addsubview:self.namelabel]; [self.contentview addsubview:self.logoimageview]; } - (void)setselected:(bool)selected animated:(bool)animated { [super setselected:selected animated:animated]; } @end i'm sure it's simple mistake. care open eyes? thanks!
use dequeuereusablecellwithidentifier
static nsstring * cellidentifier = @"schoolstableviewcell"; schoolstableviewcell *cell = (schoolstableviewcell*)[tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { nsarray *nib = [[nsbundle mainbundle] loadnibnamed:@"schoolstableviewcell" owner:self options:nil]; cell = [nib objectatindex:0]; }
Comments
Post a Comment