Cómo transformar la barra de navegación y el controlador de navegación en modo horizontal
-
03-07-2019 - |
Pregunta
Estoy desarrollando un juego en el que estoy usando el modo Paisaje. Tengo un total de 4 vistas. 2 vistas vienen correctamente en modo horizontal. Pero en la tercera vista tengo UITable y barra de navegación. Puedo rotar la mesa en modo horizontal pero no puedo transformar la barra de navegación ni el controlador de navegación. La barra de navegación y el controlador de navegación también tienen un botón. Tampoco se transforma. Entonces, ¿alguien puede tener la solución a esto? :)
Solución
Transforme la barra de navegación del controlador de nagvigation rotaiong con 90 grados. También es posible que deba configurar el centro de la barra de navegación y el marco para configurar el ancho adecuado para que se ajuste al modo horizontal ... funcionó para mí :) Espero que te ayude a ti también.
Otros consejos
#define degreesToRadians(x) (M_PI * x / 180.0)
- (void)viewWillAppear:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
CGRect newBounds = CGRectMake(0, 0, 480, 320);
self.navigationController.view.bounds = newBounds;
self.navigationController.view.center = CGPointMake(newBounds.size.height / 2.0, newBounds.size.width / 2.0);
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
[super viewWillAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
self.navigationController.view.transform = CGAffineTransformIdentity;
self.navigationController.view.transform = CGAffineTransformMakeRotation(degreesToRadians(0));
self.navigationController.view.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);
[super viewWillDisappear:animated];
}
En la clase de documentación de UIViewController:
Manejo de rotaciones
propiedad interfaceOrientation
- shouldAutorotateToInterfaceOrientation:
- rollingFooterView
- rotativoHeaderView
- willRotateToInterfaceOrientation: duration:
- willAnimateFirstHalfOfRotationToInterfaceOrientation: duration:
- willAnimateSecondHalfOfRotationFromInterfaceOrientation: duration:
- didRotateFromInterfaceOrientation:
espero que esto te ayude también.
A.