2017-12-14 4 views
0

Ich habe eine App, wo ich verstecken und Tabbar auf ein Ereignis, unten ist die Methode, die ich verwende, wenn ich versuche, es zu verstecken, funktioniert es gut. Aber wenn ich versuche, es sichtbar zu machen, funktioniert es nicht.Tabbar nicht sichtbar machen

-(void)setTabBarVisible:(BOOL)visible animated:(BOOL)animated completion:(void (^)(BOOL))completion { 

    // RootViewController* tabBarController = (RootViewController*)self.navigationController.parentViewController.parentViewController; 
    UITabBarController *tabBarController = self.tabBarController; 

    CGFloat duration = (animated)? 0.3 : 0.0; 

    CGRect frame = tabBarController.tabBar.frame; 
    CGFloat height = frame.size.height; 
    CGFloat offsetY = (visible)? -height : height; 


    CGRect playerFrame = player.view.frame; 
    CGRect toolBarFrame = self.toolbar.frame; 

    [UIView animateWithDuration:duration animations:^{ 

     CGRect fr = CGRectOffset(frame, 0, offsetY); 
     tabBarController.tabBar.frame = fr; 
     if((!visible && ![self toolBarOnBottom]) || visible) { 
      self.toolbar.frame = CGRectOffset(toolBarFrame, 0, offsetY); 
      [self.toolbar layoutIfNeeded]; 
     } 

    } completion:completion]; 


} 

ich, wenn ich Debug-Code das zweite Mal, dass ich diese Methode aufrufen, um es sichtbar zu machen, die Tabbar Rahmen Null ist, ich denke, das ist das Problem. Ich teste das auf Xcode 9 mit iOS 11 SDK. Ich bin mir nicht sicher, ob Safe Area etwas damit zu tun hat.

Jede Hilfe wäre willkommen.

+0

1. Ist durch Zufall '' tabBarController' nil'? 2. Wann nennst du diese Methode? (Von welchen anderen Methoden). 3. Verwenden Sie das automatische Layout? – danypata

+0

Tabbarcontroller ist nicht Null, und ja ich benutze Auto-Layout –

Antwort

Verwandte Themen