Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li><p>If you use <code>settings bundle to manage preferences from the Settings app</code>:</p> <p>From what you said in your question, you already know how to get a notification(<code>UIApplicationDidBecomeActiveNotification</code>) when your app becomes active, right?</p> <p>If so, the only problem left is how to reload your view after you receive the notification. Other than <code>UITableView</code>, which can be easily reloaded by calling <code>[tableView reloadData]</code>, you have to reload your view by assigning values to the UI controls that you want to reload just as you set them up initially. Say you have a <code>UILabel</code> label you want to reload with the newly set preference value, you just write code like this:</p> <pre><code>- (void)reloadView { label.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"PreferenceKey"]; self.view.background = … [self.tableView reloadData]; } - (void)reloadViewOnAppActivation:(NSNotification *)notif { [self reloadView]; } </code></pre></li> <li><p>If you are using <code>in app preferences setting</code>:</p> <ol> <li><p>If the preferences view controller does not display simultaneously with the SplitViewController. Reload your views in their controllers' <code>viewWillAppear:</code> methods:</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self reloadView]; // See the definition of reloadView above } </code></pre></li> <li><p>Otherwise, make the SplitViewController the delegate of, or assign it to an ivar of, the preferences view controller, and notify it of the preferences changes when appropriate — immediately after changing any single preference if you prefer in realtime update, or after all the changes are done if you prefer batch update:</p> <pre><code>// SplitViewController methods: - (void)preferencesAreChanged { [self reloadView]; // See the definition of reloadView above } // Preferences view controller methods: // Immediate update, use a preference controlled by a `UISegmentedControl` as an example - (void)viewDidLoad { [super viewDidLoad]; … [segmentedControl addTarget:self action:@selector(xPreferenceTogglingAction:) forControlEvents:UIControlEventValueChanged]; … } - (IBAction)xPreferenceTogglingAction:(id)sender { // Update the x preference. … [delegate preferencesAreChanged]; } // Batch update - (void)viewWillDisappear:(BOOL)animated { [delegate preferencesAreChanged]; [super viewWillDisappear:animated]; } </code></pre></li> </ol></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload