I need to load different background images in first ViewController's UIImageView called background , depends on what settings is used for toggle switch in Settings Bundle.
In -viewWillAppear in ViewController.m
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id toggleSwitchValue = [defaults objectForKey:@"PSToggleSwitchSpecifier"];
BOOL boolToggle = [toggleSwitchValue boolValue];
// setting custom back for viewController
if (boolToggle == YES) {
[self.backGround setImage:[UIImage imageNamed:@"1.png"]];
NSLog(@"YES");
} else if (boolToggle == NO) {
[self.backGround setImage:[UIImage imageNamed:@"2.png"]];
NSLog(@"NO");
}
I haven't warnings but i can't set image what will be used.
Any ideas to solve?
Make sure that, if the view is loaded from a nib, you modify the view in or after viewDidLoad.
Make sure your IBOutlet is wired up correctly and use [background setImage:] instead of dot notation. If neither works, you have an issue with your logic or setting/reading of the userDefault value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With