ios - UILabel is not receiving string from imp file -
i have objective-c class subclass of uiviewcontroller. isn't main view, accessed when button pushed viewcontroller through segue in storyboard. both attached navigation controller switch around fine. however, have problem. in "displayview.m" file (the second view), make calculations , want set text of label. know there aren't problems calculation portion of code, because when nslog string, comes out fine. however, label not change. setup displayview scene in storyboard:
- custom class of "displayview" set
- label linked iboutlet
here's imp file displayview.m if helps. please let me know if need additional details. things i've tried:
- creating new method print text
- logging output supposed show up, console (works perfect)
- trying different label
- trying use label objects without @property
- trying settext non formatted string
none of these tests worked, , can't seem find problem is. new view loads without label. however, if change label text in storyboard, show up. isn't showing of values code.
displayview.m
#import "displayview.h" @interface displayview () @end @implementation displayview @synthesize months,days,seconds; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } -(void)calc:(int)m with:(int)d andwith:(int)y { nsstring* bday = [nsstring stringwithformat:@"%i-%i-%i 00:00:00 +0000",m,d,y]; nsdateformatter *formatter = [nsdateformatter new]; [formatter setdateformat:@"ll-dd-yyyy 00:00:00 +0000"]; nsdate *date1 = [formatter datefromstring:bday]; nsdate *date2 = [nsdate date]; nstimeinterval secondsbetween = [date2 timeintervalsincedate:date1]; int numberofdays = secondsbetween/86400; [days settext:@"asdadas"]; } @end
displayview.h
#import <uikit/uikit.h> @interface displayview : uiviewcontroller { iboutlet uilabel* months; iboutlet uilabel* days; iboutlet uilabel* seconds; } -(void)calc:(int)m with:(int)d andwith:(int)y; @property uilabel* months; @property uilabel* days; @property uilabel* seconds; @end
Comments
Post a Comment