Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First I voted up the previous answer, but then I noticed how ridiculously complex it is. It can and should be simplified.</p> <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application { NSArray *initialViewControllers = [NSArray arrayWithArray:self.tabBarController.viewControllers]; NSArray *tabBarOrder = [[AppDelegate sharedSettingsService] tabBarOrder]; if (tabBarOrder) { NSMutableArray *newViewControllers = [NSMutableArray arrayWithCapacity:initialViewControllers.count]; for (NSNumber *tabBarNumber in tabBarOrder) { NSUInteger tabBarIndex = [tabBarNumber unsignedIntegerValue]; [newViewControllers addObject:[initialViewControllers objectAtIndex:tabBarIndex]]; } self.tabBarController.viewControllers = newViewControllers; } NSInteger tabBarSelectedIndex = [[AppDelegate sharedSettingsService] tabBarSelectedIndex]; if (NSIntegerMax == tabBarSelectedIndex) { self.tabBarController.selectedViewController = self.tabBarController.moreNavigationController; } else { self.tabBarController.selectedIndex = tabBarSelectedIndex; } /* Add the tab bar controller's current view as a subview of the window. */ [self.window addSubview:self.tabBarController.view]; } - (void)applicationWillTerminate:(UIApplication *)application { NSInteger tabBarSelectedIndex = self.tabBarController.selectedIndex; [[AppDelegate sharedSettingsService] setTabBarSelectedIndex:tabBarSelectedIndex]; [[NSUserDefaults standardUserDefaults] synchronize]; } - (void)tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray *)viewControllers changed:(BOOL)changed { NSUInteger count = tabBarController.viewControllers.count; NSMutableArray *tabOrderArray = [[NSMutableArray alloc] initWithCapacity:count]; for (UIViewController *viewController in viewControllers) { NSInteger tag = viewController.tabBarItem.tag; [tabOrderArray addObject:[NSNumber numberWithInteger:tag]]; } [[AppDelegate sharedSettingsService] setTabBarOrder:[NSArray arrayWithArray:tabOrderArray]]; [tabOrderArray release]; } </code></pre> <p>All this happens in AppDelegate. You set UITabBarController's delegate to AppDelegate instance in Interface Builder. sharedSettingsService is what persists the data for me. Basically it can be a NSUserDefaults front-end or anything you like (CoreData for example). So everything is simple, Interface Builder helps here, not makes things more complex.</p>
 

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