1

I am working on tabbar application. When application started, by default first tab is selected.

What I want to is when I start application, tab bar should be displayed without selected tab. Like say, if i have 4 tabs then non them get selected when application get launched. By default first one get selected.

I want to display some views which are not part of any of tabs.

Is it possible to do ?

Thanks...

Maulik
  • 19,348
  • 14
  • 82
  • 137

3 Answers3

1

If you have a visible tabBarController, then something will necessarily be selected. No way around this.

However, if you would like to hide the tabBar, then you can certainly do that, either by setting its hidden property to YES or by presenting a modal view on top of the selected tab (e.g. the first viewController).

PengOne
  • 48,188
  • 17
  • 130
  • 149
1

Yes it is possible to display views that are not part of one of the view controllers managed by the tabbar controller. There are many way to do that.
You can present a view controller modally, or just add a subview in the tabbar controller's view.

But as long as the tabbar controller get instanciated, there are no way to deselect every tab.

1

Yes, this is possible.

You need to create a view programmatically and add that view in Window as SuperView , when you don't need it just remove it form SuperView.

[SuperViewname removeFromSuperView];

Code Snippet:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    // Add the tab bar controller's view to the window and display.
    [self.window addSubview:tabBarController.view];
        [self.window makeKeyAndVisible];


**AdditionalView**
//======================= LoginView ================================================
    loginview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    imgview_logingpage=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    imgview_logingpage.image=[UIImage imageNamed:@"Screen.jpg"];

    loginview.backgroundColor=[UIColor blackColor];


        [self.window addSubview:Viewnavigation.view];
    [self.window addSubview:loginview];  // To add the View in Window View

}

// To REmove the View from SuperView -(void)login_clicked:(id)sender {

        Homepage *obj_homepage=[[Homepage alloc]initWithNibName:@"Homepage" bundle:nil];
        [self.window addSubview:obj_homepage.view];
        [loginview removeFromSuperview];
        [loginview release];
}

Or either the more easy way is : Open a new view via PresentModalViewController

Ajay Sharma
  • 4,509
  • 3
  • 32
  • 59
  • yes i know this approach...but tab bar should be displayed at same time. – Maulik Jul 21 '11 at 06:44
  • No it is not feasilbe.... If you are using the Tab controller then any of the tab would be selected.... better to use any view & have Custom Toolbar which will give the illusion of TAbbarcontroller . Otherthan that it;s seems to be quite impossible – Ajay Sharma Jul 21 '11 at 10:54