Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've managed to accomplish this using <a href="http://developer.apple.com/library/mac/#featuredarticles/KeyValueObserving_QuickStart/Introduction/Introduction.html" rel="noreferrer">KVO</a> tricks.</p> <p>The idea is simple: we track down when UITabBarController tries to set its selectedViewController property and immediately set it back to nil.</p> <p>Example code:</p> <pre><code>- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Create the view controller which will be displayed after application startup mHomeViewController = [[HomeViewController alloc] initWithNibName:nil bundle:nil]; [tabBarController.view addSubview:mHomeViewController.view]; tabBarController.delegate = self; [tabBarController addObserver:self forKeyPath:@"selectedViewController" options:NSKeyValueObservingOptionNew context:NULL]; // further initialization ... } // This method detects if user taps on one of the tabs and removes our "Home" view controller from the screen. - (BOOL) tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController { if (!mAllowSelectTab) { [mHomeViewController.view removeFromSuperview]; mAllowSelectTab = YES; } return YES; } // Here we detect if UITabBarController wants to select one of the tabs and set back to unselected. - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (!mAllowSelectTab) { if (object == tabBarController &amp;&amp; [keyPath isEqualToString:@"selectedViewController"]) { NSNumber *changeKind = [change objectForKey:NSKeyValueChangeKindKey]; if ([changeKind intValue] == NSKeyValueChangeSetting) { NSObject *newValue = [change objectForKey:NSKeyValueChangeNewKey]; if ([newValue class] != [NSNull class]) { tabBarController.selectedViewController = nil; } } } } } </code></pre> <p>However, one small note: the first view controller from tabbar still will be loaded (although for a very short time), so its viewDidLoad and viewWillAppear will be called after startup. You may want to add some logic to prevent some initializations you probably may do in these functions until "real" display of that controller as a result of user tap (using for example global variables or NSNotificationCenter).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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