0
votes

I have created a universal application for iPhone and iPad. In this application, the iPhone is navigation type and the iPad is tab bar type. The iPhone supports both landscape and portrait orientation, the iPad application supports only landscape.

In the iPad I am displaying the TabBarController after the login window (present model view), when I run the iPad application first time it always run in the portrait mode. Even if I set the orientation mode to landscape and also should auto rotate for landscape.

So please can any one suggest me where I am wrong or how I forcefully display the view in landscape mode.

2

2 Answers

1
votes

I forcefully changed the orientation using below code. and its works fine for me:

if ([[UIDevice currentDevice] respondsToSelector:@selector (setOrientation:)]) {
  SEL selector = NSSelectorFromString (@" setOrientation:");
  NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
  [invocation setSelector:selector];
  [invocation setTarget:[UIDevice currentDevice]];
  int Val = UIInterfaceOrientationLandscapeRight;
  [invocation setArgument:& val atIndex:2];
  [invocation invoke];
 }

Thanks

0
votes

Just add below code in your applicationdelegate.m file

self.window.rootViewController = self.navController;

and also remove [self.window addSubview:self.navController.view];

this will definitely working..