InAppSettings
InAppSettings copied to clipboard
Reload if a setting is changed in the settings app while in background
If the in app settings controller is visible, if you leave the app and go to the Settings app and change a setting, when you come back to the app the settings controller still has the old values. Fix with these changes:
- (void)viewWillAppear:(BOOL)animated { ... [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil]; }
- (void)viewWillDisappear:(BOOL)animated{ ... [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil]; } -(void)applicationWillEnterForeground:(NSNotification*)notify{ // reload in settings in case they were changed in the prefs app. [[NSUserDefaults standardUserDefaults] synchronize]; // show any changes if they happened in the background. [self.tableView reloadData]; }