sathish kumar
sathish kumar

Reputation: 1109

Orientation issues in UITabbar application

I am working on tab bar application in which i called navigation controller on following way The problem is i cannot able to oriented to Landscape mode. can anybody please say what i went wrong?

Regards, sathish

-(IBAction)click


{

    tabBarController = [[UITabBarController alloc] init];

    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:5];

    UINavigationController *localNavigationContriller;

    FavouritesViewController *master;
    master = [[FavouritesViewController alloc] initWithTabBar];
    localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:master];
    [localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
     [localControllersArray addObject:localNavigationContriller];
    //[localNavigationContriller release];
    [master release];

    NeedViewController *need;
    need = [[NeedViewController alloc] initWithTabBar];
    localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:need];
    [localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
    [localControllersArray addObject:localNavigationContriller];
    //[localNavigationContriller release];
    [need release];

    DontNeedViewController *dontneed;
    dontneed = [[DontNeedViewController alloc] initWithTabBar];
    localNavigationContriller=[[UINavigationController alloc] initWithRootViewController:dontneed];
    [localNavigationContriller.navigationBar setBarStyle:UIBarStyleBlackTranslucent];
    [localControllersArray addObject:localNavigationContriller];
    //[localNavigationContriller release];
    [dontneed release];

    tabBarController.delegate=self;
    tabBarController.viewControllers = localControllersArray;
    [localControllersArray release];

    [[[UIApplication sharedApplication] keyWindow] addSubview:tabBarController.view];
}

Upvotes: 0

Views: 447

Answers (2)

Suresh Varma
Suresh Varma

Reputation: 9740

It's not possible to change the orientation for one view in a tabBar and not for another. If a TabBar is specified then all the subviews (tabs) must have the same orientation appearance. You must set the orientation in each ViewController and in the TabBarController.

So just add this in all the tabbar's main Controllers

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return YES;

    return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}

In your Case those controllers where this code is to be added are FavouritesViewController, NeedViewController & DontNeedViewController

Upvotes: 0

Mushtque Ahmed
Mushtque Ahmed

Reputation: 21

Listen dude u you have to override the shouldrotate function to YES in all the tab bar , like you have 3 tab bar in your app , go to there respective class and

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    // Return YES for supported orientations.

    return YES;
}

in all the respective class of the tab bar... hope that help , if it does pray for me ...

Upvotes: 1

Related Questions