Maulik
Maulik

Reputation: 19418

How to Deselect tab when application is loaded

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...

Upvotes: 1

Views: 302

Answers (3)

Ajay Sharma
Ajay Sharma

Reputation: 4517

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

Upvotes: 1

user756245
user756245

Reputation:

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.

Upvotes: 1

PengOne
PengOne

Reputation: 48398

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).

Upvotes: 1

Related Questions