ios - UILabel Not Updating After Segue -
i segue uiviewcontroller, , during init method, 2 labels' text supposed specified. however, doesn't happen , text never changes. connections right, aren't displaying anything, , can't figure out why.
below code supposed change uilabels particular viewcontroller.
-(id)initwithcoder:(nscoder *)adecoder{ if (self = [super initwithcoder:adecoder]) { _namelabel.text = @"name"; _addresslabel.text = @"address"; } return self; }
below ".h" file it:
@property (strong, nonatomic) location *selectedlocation; @property (weak, nonatomic) iboutlet uilabel *namelabel; @property (weak, nonatomic) iboutlet uilabel *addresslabel;
any thoughts?
i guess initwithcoder:
not called. recommended set data want in viewdidload
.
- (void)viewdidload { [super viewdidload]; self.namelabel.text = @"name"; self.addresslabel.text = @"address"; }
if not solved, check views state, such frame, hidden or alpha value.
- (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; nslog(@"[namelabel] frame : %@, hidden : %d, alpha : %@", nsstringfromrect(self.namelabel.frame), self.namelabel.hidden, self.namelabel.alpha); nslog(@"[addresslabel] frame : %@, hidden : %d, alpha : %@", nsstringfromrect(self.addresslabel.frame), self.addresslabel.hidden, self.addresslabel.alpha); }
updated: it's because of iboutlet nil
in function initwithcoder:
.
Comments
Post a Comment