ios - cell properties returned nil -
i created custom uitableviewcell named gatecell, inside placed 1 label , 1 text field.
in gatecell.h
@property (weak, nonatomic) iboutlet uilabel *gatelabel; @property (weak, nonatomic) iboutlet uitextfield *gatetextfield; in gatetableviewcontroller
- (void)viewdidload { [self.tableview registerclass:[gatecell class] forcellreuseidentifier:@"cellidentifier"]; } finally @ cellforrowatindexpath method, used this
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { gatecell *cell = (gatecell *)[tableview dequeuereusablecellwithidentifier:@"cellidentifier"]; cell.gatelabel.text = @"gate"; cell.gatetextfield.text = @"open gate" return cell; } when print description of cell, getting following..
<`gatecell`: 0x7b6bd790; baseclass = `uitableviewcell`; frame = (0 0; 320 44); layer = <calayer: 0x7b6c2e60>> <br> printing description of cell->_gatelabel:
nil
printing description of cell->_gatetextfield:
nil
why label , textfield returns nil when cell created ???
first thing ensure connected iboutlet interface builder. if not connect iboutlet. getting cell use following
uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cellreuseidentifier"];
Comments
Post a Comment