1

J'ai une barre de tabulation interne UIViewController. Pour un VC dans la barre d'onglet, je permets à l'interface de tourner lors de la rotation du périphérique. Le défi est, que je veux cacher la barre d'onglets et redimensionner ma vue à l'intérieur.Barre de superposition avec vue

Ce que je l'ai fait:

1) appelé - (void)willAnimateRotation.... dans mon contrôleur de barre d'onglets et mis self.tabBar.isHidden à true -> la barre d'onglets disparaissaient.

2) appelé - (void)willAnimateRotation.... et réglé self.mapView.frame à la hauteur maximale. MAIS ... J'ai toujours une bande noire dans le bas de l'écran dans la taille exacte de la barre d'onglets. Existe-t-il un moyen de faire disparaître complètement la barre d'onglets?

Répondre

1
[self hideTabBar:self.tabBarController]; 


- (void) hideTabBar:(UITabBarController *) tabbarcontroller { 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.5]; 
    for(UIView *view in tabbarcontroller.view.subviews) 
    { 
     if([view isKindOfClass:[UITabBar class]]) 
     { 
      [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)]; 
     } 
     else 
     { 
      [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)]; 
     } 

    } 
    [UIView commitAnimations];  
} 
+0

Works grande, sous la direction de la fonction de travailler en arrière aussi bien. Merci beaucoup! – Michal

+0

Votre bienvenue ... :) – Rajneesh071

1

Cela a fonctionné pour moi

- (void)viewDidLoad { 
    [super viewDidLoad];  
    previousRect = self.view.frame;  
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return YES; 
} 

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration; 
{ 
    if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {    
     [self.navigationController setNavigationBarHidden:TRUE animated:FALSE]; 
     [[UIApplication sharedApplication] setStatusBarHidden:TRUE animated:FALSE]; 
    } 
    else 
    { 
     [self.navigationController setNavigationBarHidden:FALSE animated:FALSE]; 
     [[UIApplication sharedApplication] setStatusBarHidden:FALSE animated:FALSE]; 
    } 
} 

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    UIInterfaceOrientation toOrientation = self.interfaceOrientation; 

    if (self.tabBarController.view.subviews.count >= 2) 
    { 
     UIView *transView = [self.tabBarController.view.subviews objectAtIndex:0]; 
     UIView *tabBar = [self.tabBarController.view.subviews objectAtIndex:1]; 

     if(toOrientation == UIInterfaceOrientationLandscapeLeft || toOrientation == UIInterfaceOrientationLandscapeRight) {          
       transView.frame = CGRectMake(0, 0, 480, 320); 
       tabBar.hidden = TRUE; 
     } 
     else 
     {        
       transView.frame = previousRect;   
       tabBar.hidden = FALSE; 
     } 
    } 
} 
1

Si vous voulez cacher toujours la barre d'onglets lorsqu'un particulier UIViewController est poussé, vous pouvez le faire:

self.hidesBottomBarWhenPushed = YES; 
Questions connexes