Am using iOS6 device xcode 4.5 & mountain lion mac. And in my app am starting in portrait mode(3 screens). But 4th screen should be in landscape and should support landscape left & landscape right.
Most of the explanations are shown how to rotate.
in appddelegate am using
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
navigationController.navigationBar.tintColor = [UIColor blackColor];
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[self.window addSubview: navigationController.view];
}
else
{
// use this mehod on ios6
[self.window setRootViewController:navigationController];
}
}
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if(self.shouldRotate ) //shouldRotate is my flag
{
self.shouldRotate = NO;
return (UIInterfaceOrientationMaskLandscapeRight);
}
return (UIInterfaceOrientationMaskPortrait);
}
and in my view controller which should be landscape and am using
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
appDelegate.shouldRotate = YES;
// Custom initialization
}
return self;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
In my viewcontrollers which are potrait are working correctly in which am using
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
can any one suggest to do this
Thanks in advance