¿Por qué no puedo forzar la orientación horizontal cuando uso UINavigationController?
Encuentro muchas preguntas para forzar a UIViewController a paisaje como predeterminado:Cómo forzar a un UIViewController a orientación vertical en iOS 6 Y prueba esto:
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Pero cuando uso UIViewController dentro de UINavigationController, no puedo forzar el paisaje. ¡Por favor, ayuda!
* Trabajo NO ok
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
UINavigationController *navControl = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[navControl setNavigationBarHidden:YES];
self.window.rootViewController = navControl;
[self.window makeKeyAndVisible];
return YES;
}
* Trabaja OK:
self.window.rootViewController = self.viewController;