2010-11-18 4 views
0

Je travaille sur une application de barre d'onglets dans laquelle j'ai appelé le contrôleur de navigation de la manière suivante Le problème est que je ne peux pas être orienté en mode Paysage. quelqu'un peut-il s'il vous plaît dire ce que je me suis trompé?Problèmes d'orientation dans l'application UITabbar

Cordialement, 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]; 
} 

Répondre

1

Écouter mec u vous devez remplacer la fonction de shouldrotate YES dans toute la barre d'onglets, comme vous avez 3 barre d'onglets dans votre application, allez y classe et

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

    return YES; 
} 

dans toute la classe respective de la barre d'onglets ... espérons que l'aide, si elle ne prie pour moi ...

0

il est impossible de chan ge l'orientation pour une vue dans un tabBar et non pour un autre. Si un TabBar est spécifié alors toutes les sous-vues (onglets) doivent avoir la même apparence d'orientation. Vous devez définir l'orientation dans chaque ViewController et dans le TabBarController.

Il suffit donc d'ajouter ceci dans tous les principaux contrôleurs de la TabBar

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

    return toInterfaceOrientation != UIInterfaceOrientationPortraitUpsideDown; 
} 

Dans votre cas ces contrôleurs où ce code doit être ajouté sont FavouritesViewController, NeedViewController & DontNeedViewController