Cómo llamar a shouldAutorotate utilizando un UITabBarController

mayo 13th, 2012 Posted by Sin categoría 0 thoughts on “Cómo llamar a shouldAutorotate utilizando un UITabBarController”

Para que el método shouldAutorotate pueda ser llamado desde un ViewController que es parte de un UITabBarController hay que extender la clase UITabBarController.

En el h

#import 

@interface MyTabBarController : MyTabBarController

@end

Y para permitir que la aplicación rote en determinado controller poner en el m 

#import "MyTabBarController.h"
#import "MyViewController.h"

@implementation MyTabBarController

- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
NSLog(@"Pasando");
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
if(self.selectedIndex == 0 && [[[self.viewControllers objectAtIndex:0] visibleViewController] isKindOfClass:[MyViewController class]])
return YES;
else
return NO;
}

@end

Copyright © 2018 programadorfreelanceargentina.com

Programador Freelance Argentina