I want to set a switch to off when the app enters into background. I am trying to do it using the following code. It isn't working :( When I resume app the switch is still "on" on animation on the screen. How can I fix this?
- (void)applicationWillResignActive:(UIApplication *)application {
[registrationSwitch setOn:NO animated:YES];
}
You need to set the value in userDefaults. Add a boolean check like:
if (userDefaultBool == 1){
registrationSwitch setOn
}
else{
registration setOff
}
put that in your viewDidLoad