Domanda

Ho un UITabBarController in cui il controller di visualizzazione predefinita è un UINavigationController. Voglio essere in grado di nascondere l'UITabBar del UITabBarController quando spingo una certa visione del <=>.

Ho provato ad aggiungere:

delegate.tabBarController.hidesBottomBarWhenPushed = YES;

nel mio <=> prima di spingere la vista, ma che non sembra fare il trucco.

Eventuali suggerimenti su quello che dovrei fare o se è ancora possibile? Grazie in anticipo!

È stato utile?

Soluzione

Questo è meglio:

viewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:viewController animated:YES];

È necessario impostare hidesBottomBarWhenPushed = YES sul controller che si sta per spingere in vista ...

Altri suggerimenti

quando si lavora con storyboard è facile controller della vista di configurazione che nasconde la barra delle linguette sulla spinta, il controller della vista di destinazione è sufficiente selezionare la casella di controllo:
entrare descrizione dell'immagine qui

Sono capire come ottenere questo risolto, ho girato lo stesso problema, ma Apple ci dice anche come farlo nel campione chiamato: "The Elements" ( http://developer.apple.com/library/ios/#samplecode/TheElements/Introduction/Intro. html )

Vedere funzione qui sotto su come farlo, aggiungere questo alla funzione init della vista che si desidera spingere!

-(id) init { 
    if(self = [super init]) { 
        self.hidesBottomBarWhenPushed = YES; 
    } 
    return self; 
}

Si nasconderà automaticamente la barra delle linguette come la foto app fa sul vostro iPhone. E quando ci si sposta indietro vista primaria sarà solo visualizzare nuovamente la barra delle linguette.

In bocca al lupo

Ho provato la maggior parte delle soluzioni proposte. Alla fine nessuno di loro ha lavorato per me.

hideTabBarWhenPushed nasconde la barra delle schede non solo per il controller della vista che viene spinto successivo, ma per tutti controller di vista che vengono spinti all'interno. Per chi volevo che il controller barra delle schede di ri-apparire.

soluzione Orafaelreis' (vedi sopra) sembrava suite che la maggior parte. Ma il suo tentativo ha lavorato solo per severe orientamento verticale, nemmeno per sottosopra. Così ho dovuto ripararlo. Questo è quello che ho finalmente avuto:

#define kTabBarHeight               49 // This may be different on retina screens. Frankly, I have not yet tried.

- (void) hideTabBar:(BOOL)hide {

    // fetch the app delegate
    AppDelegate         *delegate   = [[UIApplication sharedApplication] delegate];

    // get the device coordinates
    CGRect              bounds      = [UIScreen mainScreen].bounds;
    float               width;
    float               height;

    // Apparently the tab bar controller's view works with device coordinates  
    // and not with normal view/sub view coordinates
    // Therefore the following statement works for all orientations. 
    width                   = bounds.size.width;
    height                  = bounds.size.height;

    if (hide) {

        // The tab bar should be hidden too. 
        // Otherwise it may flickr up a moment upon rotation or 
        // upon return from detail view controllers. 
        [self.tabBarController.tabBar setHidden:YES];

        // Hiding alone is not sufficient. Hiding alone would leave us with an unusable black
        // bar on the bottom of the size of the tab bar. 
        // We need to enlarge the tab bar controller's view by the height of the tab bar. 
        // Doing so the tab bar, although hidden, appears just beneath the screen. 
        // As the tab bar controller's view works in device coordinations, we need to enlarge 
        // it by the tab bar height in the appropriate direction (height in portrait and width in landscape)
        // and in reverse/upside down orientation we need to shift the area's origin beyond zero. 
        switch (delegate.tabBarController.interfaceOrientation) {
            case UIInterfaceOrientationPortrait:
                // Easy going. Just add the space on the bottom.
                [self.tabBarController.view setFrame:CGRectMake(0,0,width,height+kTabBarHeight)];
                break;

            case UIInterfaceOrientationPortraitUpsideDown:
                // The bottom is now up! Add the appropriate space and shift the rect's origin to y = -49
                [self.tabBarController.view setFrame:CGRectMake(0,-kTabBarHeight,width,height+kTabBarHeight)];
                break;

            case UIInterfaceOrientationLandscapeLeft:
                // Same as Portrait but add the space to the with but the height
                [self.tabBarController.view setFrame:CGRectMake(0,0,width+kTabBarHeight,height)];
                break;

            case UIInterfaceOrientationLandscapeRight:
                // Similar to Upside Down: Add the space and shift the rect. Just use x and with this time
                [self.tabBarController.view setFrame:CGRectMake(0-kTabBarHeight,0,width+kTabBarHeight,height)];
                break;

            default:
                break;
        }
    } else {
        // reset everything to its original state. 
        [self.tabBarController.view setFrame:CGRectMake(0,0,width,height)];
        [self.tabBarController.tabBar setHidden:NO];
    }

    return; 
}


- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{

    // It is important to call this method at all and to call it here and not in willRotateToInterfaceOrientation
    // Otherwise the tab bar will re-appear. 
    [self hideTabBar:YES];

    // You may want to re-arrange any other views according to the new orientation
    // You could, of course, utilize willRotateToInterfaceOrientation instead for your subViews. 
}

- (void)viewWillAppear: (BOOL)animated { 

    // In my app I want to hide the status bar and navigation bar too. 
    // You may not want to do that. If so then skip the next two lines. 
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];

    [self hideTabBar: YES];

    // You may want to re-arrange your subviews here. 
    // Orientation may have changed while detail view controllers were visible. 
    // This method is called upon return from pushed and pulled view controllers.   

    return;
}

- (void)viewWillDisappear: (BOOL)animated {     

    // This method is called while this view controller is pulled
    // or when a sub view controller is pushed and becomes visible
    // Therefore the original settings for the tab bar, navigation bar and status bar need to be re-instated

    [self hideTabBar:NO];

    // If you did not change the appearance of the navigation and status bar in viewWillAppear,
    // then you can skip the next two statements too. 
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

    return;
}

L'in-line commenti dovrebbero spiegare il ragionamento per ogni istruzione. Anche se, ci possono essere modi più intelligenti di codifica esso.

C'è un effetto collaterale in collaborazione con nascondere la barra di stato e di navigazione barra di troppo, che non voglio nascondere da voi ragazzi. 1. In caso di restituzione da questo controller di navigazione per il controller di navigazione chiamando poi la barra di stato e barra di navigazione sulla sovrapposizione di controllo chiamata fino a quando il dispositivo viene ruotato una volta o fino a quando la scheda relativa è stata scelta ancora una volta dopo l'altra scheda è venuto a fronte. 2. Quando il controllore vista chiamante è una vista tavolo e quando il dispositivo è in modalità orizzontale quando si ritorna al tavolo, la tabella verrà visualizzata con l'orientamento appropriato per il paesaggio ma è spiegate come se fosse ritratto. L'angolo in alto a sinistra va bene, ma alcune celle della tabella, più barra delle schede sono nascosti sotto lo schermo. Sul lato destro c'è qualche spazio libero. Anche questo è fissato ruotando il dispositivo.

Vi terrò aggiornati una volta ho trovato soluzioni per questi bug minori, ma brutto.

Ecco come si arriva a questo lavoro:

Nel Application Delegate si crea il UITabBarController. Poi si crea una UINavigationController con il suo controller radice come il controller della vista che si desidera nella scheda particolare. Quindi inserire la hidesBottomBarWhenPushed nella " viewControllers " serie del YES. in questo modo:

ViewControllerForTab1 *tab1Controller = [[ViewControllerForTab1 alloc] initWithNibName:@"ViewControllerForTab1"];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tab1Controller];

[tab1Controller release];


UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects: navController, nil];

[navController release];


[self.window addSubView:tabBarController.view];

In questo modo è possibile impostare il "UITabBar" proprietà "<=>" in qualsiasi controller vista all'interno che <=> e si nasconde la <=>.

Speranza che aiuta!

ti lascio qui il mio soluzione per questo:

#define FRAME_HIDDEN CGRectMake(0, 0, 768, 1073) //1073 = 1024 (screen) + 49 (UITabBar) 
#define FRAME_APPEAR CGRectMake(0, 0, 768,1024)

-(void) setHidden: (BOOL) hidden{
    CGRect frame = (hidden)? FRAME_HIDDEN : FRAME_APPEAR;
    [self.tabBarController.view setFrame:frame];
    [self.tabBarController.tabBar setHidden:hidden];
}

chiama il metodo 'setHidden' dove serve! I utilizzando questo e il 'pattern Singleton', poi i miei subviews possono nascondere l'UITabBar nel suo Superview

Si scopre che se si imposta la vista hidesBottomBarWhenPushed:YES nasconde la barra quando la vista appare (duh da parte mia). Mi è stato di assegnarlo alla UITabBarController, che non ha molto senso quando si pensa a questo proposito.

[self.view hidesBottomBarWhenPushed:YES];
[super pushViewController:viewController animated:animated];

nel primo UIViewController "FirstItemViewController"

 @IBAction func pushToControllerAction(sender: AnyObject) {
     self.hidesBottomBarWhenPushed = true
     self.performSegueWithIdentifier("nextController", sender: self)
 }

nel prossimo UIViewController "ExampleViewController" `

 override func willMoveToParentViewController(parent: UIViewController?) {
         if parent == nil {
             var viewControllers = self.navigationController!.viewControllers
             if ((viewControllers[viewControllers.count - 2]).isKindOfClass(FirstItemViewController.self)) {
                 (viewControllers[viewControllers.count - 2] as! FirstItemViewController).hidesBottomBarWhenPushed = false
             }
         }
 }

Guardate questa risposta https://stackoverflow.com/a/36148064/3078925

Utilizzare hidesBottomBarWhenPushed nel controllore che si desidera nascondere.

Per nascondere tutti i controller messo in prepare for segue

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    segue.destination.hidesBottomBarWhenPushed = true
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top