Reputation: 1696
I've dragged a button using storyboard and created IBoutlet for it in .h file also synthesised it.
Now i'm trying to change the text of the button but it is not working for me.
- (id)initWithCoder:(NSCoder *)decoder
{
if ((self = [super initWithCoder:decoder]))
{
configDetails *updatedConfig=[[configDetails alloc]init];
[updatedConfig setAllItemstext:@" Go to AllItems"];
[updatedConfig setAboutUstext:@"Text for AboutUs button"];
[updatedConfig setHomeScreenTitleColor:@"Yellow"];
NSString *newtext=[updatedConfig aboutUstext];
NSLog(@"%@",newtext);
[aboutUs setTitle:[updatedConfig aboutUstext] forState:UIControlStateNormal];
[allItems setTitle:[updatedConfig allItemstext] forState:UIControlStateNormal];
}
return self;
}
Upvotes: 0
Views: 150
Reputation: 3311
You can't set your IBOutlet properties in initWithCoder
method .
See my answer about this
Upvotes: 0
Reputation: 15015
Try like this write your code into viewDidAppear
:-
-(void)viewDidAppear:(BOOL)animated{
configDetails *updatedConfig=[[configDetails alloc]init];
[updatedConfig setAllItemstext:@" Go to AllItems"];
[updatedConfig setAboutUstext:@"Text for AboutUs button"];
[updatedConfig setHomeScreenTitleColor:@"Yellow"];
NSString *newtext=[updatedConfig aboutUstext];
NSLog(@"%@",newtext);
[aboutUs setTitle:[updatedConfig aboutUstext] forState:UIControlStateNormal];
[allItems setTitle:[updatedConfig allItemstext] forState:UIControlStateNormal];
[super viewDidAppear:animated];
}
Upvotes: 1