mac for descargar ios xcode

ios - for - xcode mac



Ocultando tabBar mostrando barra negra en Ios7 (9)

Además de las otras excelentes sugerencias, la siguiente sugerencia podría ayudar a alguien. Intente configurar su barra de pestañas en oculto en awakeFromNib en lugar de más adelante en el ciclo de vida. Descubrí que el tabbar oculto parpadeaba en negro en Segue y esto lo solucionó.

- (void)awakeFromNib { [super awakeFromNib]; self.tabBarController.tabBar.hidden = YES; }

Estoy usando este código para ocultar el TabBar:

self.tabBarController.tabBar.hidden=YES;

Estoy ocultando tabBarController en mi proyecto, pero muestra una barra negra en la parte inferior de la vista en Ios7. Cuando vuelva a la misma vista, se verá bien. Cualquier ayuda será apreciada.


Basado en la solución de @Vadim Trulyaev, creé un uso simple:

UITabBarController + HideTabBar.h

@interface UITabBarController (Additions) - (void)setTabBarHidden:(BOOL)hidden myClass:(UIViewController *)myClass; @end

UITabBarController + HideTabBar.m

#import "UITabBarController+HideTabBar.h" @implementation UITabBarController (HideTabBar) - (void)setTabBarHidden:(BOOL)hidden myClass:(UIViewController *)myClass{ if ([myClass respondsToSelector:@selector(setExtendedLayoutIncludesOpaqueBars:)]) { //iOS 7 - hide by property NSLog(@"iOS 7"); [myClass setExtendedLayoutIncludesOpaqueBars:hidden]; self.tabBar.hidden = hidden; } else { //iOS 6 - move TabBar off screen NSLog(@"iOS 6"); CGRect screenRect = [[UIScreen mainScreen] bounds]; float height = screenRect.size.height; if(hidden){ [self moveTabBarToPosition:height]; }else{ [self moveTabBarToPosition:height - self.tabBar.frame.size.height]; } } } //Moving the tab bar and its subviews offscreen so that top is at position y -(void)moveTabBarToPosition:(int)y { self.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, y, self.tabBar.frame.size.width, self.tabBar.frame.size.height); for(UIView *view in self.view.subviews) { if ([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)]; } else { NSLog(@"%f",view.frame.size.height); [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)]; NSLog(@"%f",view.frame.size.height); view.backgroundColor = [UIColor blackColor]; } } } @end

Cómo utilizar:

[[self tabBarController] setTabBarHidden:NO myClass:self];

PERO, en iOS6 tengo algún problema, cuando voy por primera vez a ViewController1 donde la barra de pestañas está oculta, todo funciona bien, pero si voy a un ViewController2 que muestra la barra de pestañas y de nuevo a ViewController1 que la barra de pestañas debe estar oculta, el espacio negro aparece. ¡¿Alguien puede ayudarme?!

¡Gracias!


El siguiente código funciona para mí

- (void)showTabBar { [self.tabBar setTranslucent:NO]; [self.tabBar setHidden:NO]; } - (void)hideTabBar { [self.tabBar setTranslucent:YES]; [self.tabBar setHidden:YES]; }


NOTA: es una solución solo para iOS6 y 7.

En iOS 7 para ampliar el área en la que se puede hacer clic y ocultar la barra negra en lugar de UITabBar oculto, debe habilitar la opción ''Extender bordes - Bajo barras opacas'' para usted UIViewController.

O puede establecer esta propiedad mediante programación:

[self setExtendedLayoutIncludesOpaqueBars: YES]

Aquí hay un ejemplo de código que oculta o mueve TabBar para iOS 6/7:

UITabBarController *bar = [self tabBarController]; if ([self respondsToSelector:@selector(setExtendedLayoutIncludesOpaqueBars:)]) { //iOS 7 - hide by property NSLog(@"iOS 7"); [self setExtendedLayoutIncludesOpaqueBars:YES]; bar.tabBar.hidden = YES; } else { //iOS 6 - move TabBar off screen NSLog(@"iOS 6"); CGRect screenRect = [[UIScreen mainScreen] bounds]; float height = screenRect.size.height; [self moveTabBarToPosition:height]; } //Moving the tab bar and its subviews offscreen so that top is at position y -(void)moveTabBarToPosition:(int)y { self.tabBarController.tabBar.frame = CGRectMake(self.tabBarController.tabBar.frame.origin.x, y, self.tabBarController.tabBar.frame.size.width, self.tabBarController.tabBar.frame.size.height); for(UIView *view in self.tabBarController.view.subviews) { if ([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, y, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, y)]; view.backgroundColor = [UIColor blackColor]; } } }

La función para mover la barra de pestañas fuera de pantalla obtuvo de esta publicación .


Pasé mucho tiempo luchando contra esto, tratando de colocar un botón sensible en la parte inferior de la vista de tabla. No estoy usando el diseño automático. Encontré dos diferencias principales entre iOS 6 y 7:

  1. En iOS7, cuando la barra de pestañas está animada, la vista del controlador de vista raíz no se extiende al área donde estaba la barra de pestañas; necesita ser redimensionado.

  2. En iOS7, solo la vista de tipo UITabBar debe estar animada y desactivada en la pantalla.

Otro problema con el punto 1 es que si en iOS7 extiende una vista secundaria de la vista principal del controlador de vista visible sobre el espacio dejado por la vista de pestaña, no será interactuable a menos que la vista principal también se extienda. Con eso en mente, utilicé el siguiente código:

Ocultar la barra de pestañas (invierta la matemática así que muéstrese):

[UIView animateWithDuration:kHideTabBarAnimationDuration animations:^{ for(UIView *view in self.tabBarController.view.subviews) { if([view isKindOfClass:[UITabBar class]]) { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y + view.frame.size.height, view.frame.size.width, view.frame.size.height)]; } else { if (![MYDeviceUtility systemVersionGreaterThanOrEqualTo:@"7.0"]) { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height + self.tabBarController.tabBar.frame.size.height)]; } } } } completion:nil];

Ajuste la vista principal al ocultar la barra de pestañas:

// Expand view into the tab bar space if ([MYDeviceUtility systemVersionGreaterThanOrEqualTo:@"7.0"]) { CGRect frame = self.view.frame; self.view.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height + tabBarHeight); }

Ajuste la vista principal al revelar la barra de pestañas:

[UIView animateWithDuration:kHideTabBarAnimationDuration delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{ // Create space for the tab bar if ([MYDeviceUtility systemVersionGreaterThanOrEqualTo:@"7.0"]) { CGRect frame = self.view.frame; self.view.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height - tabBarHeight); } } completion:nil];

Tenga en cuenta que no animo la expansión de la vista principal al ocultar la barra de pestañas, esto parece natural ya que la expansión ocurre detrás de la barra de pestañas.

También tenga en cuenta

En iOS 7, si gira de vertical a horizontal mientras la barra de pestañas está oculta, reaparece la caja negra. Lo resolví animando la barra de pestañas en la pantalla antes de la animación de rotación (que era lo suficientemente buena para lo que estoy trabajando).


Prueba esto:

- (BOOL)hidesBottomBarWhenPushed { return YES; }


Tuve algunos problemas al usar un UINavigationController:

Aquí está mi solución que funciona para iOS 7 y UINavigationControllers:

Archivo de cabecera

@interface UITabBarController (HideTabBar) - (void)setHideTabBar:(BOOL)hide animated:(BOOL)animated; @end

Implementación

#import "UITabBarController+HideTabBar.h" @implementation UITabBarController (HideTabBar) - (void)setHideTabBar:(BOOL)hide animated:(BOOL)animated { UIViewController *selectedViewController = self.selectedViewController; /** * If the selectedViewController is a UINavigationController, get the visibleViewController. * - setEdgesForExtendedLayout won''t work with the UINavigationBarController itself. * - setExtendedLayoutIncludesOpaqueBars won''t work with the UINavigationBarController itself. */ if ([selectedViewController isKindOfClass:[UINavigationController class]]) selectedViewController = ((UINavigationController *)selectedViewController).visibleViewController; __weak __typeof(self) weakSelf = self; void (^animations)(void) = ^{ selectedViewController.edgesForExtendedLayout = UIRectEdgeAll; [selectedViewController setExtendedLayoutIncludesOpaqueBars:hide]; weakSelf.tabBar.hidden = hide; /** * Just in case we have a navigationController, call layoutSubviews in order to resize the selectedViewController */ [selectedViewController.navigationController.view layoutSubviews]; }; [UIView animateWithDuration:animated ? UINavigationControllerHideShowBarDuration : 0 animations:animations]; } @end

¡Gracias a Vadim Trulyaev por señalar la bandera Extend Edges - Under Opaque Bars !


Una línea Swift 3 respuesta.

Coloque lo siguiente en su subclase UIViewController:

override var hidesBottomBarWhenPushed: Bool { get { return true } set { self.hidesBottomBarWhenPushed = newValue }}


To showTabbar: - (void)showTabBar:(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, 521, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 521)]; } } // [UIView commitAnimations]; } To hide Tabbar: - (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, 568, view.frame.size.width, view.frame.size.height)]; } else { [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 568)]; } } //[UIView commitAnimations]; }