0

I am creating an application in iPhone. In that i want first UIViewController opens in Portrait mode and second UIViewController opens in Landscape mode.

I tried this link iOS 6: how to force change orientation when pushing view controller into the navigation controller stack

But it's not woking ….

Is there any solution to solve this problem.

Community
  • 1
  • 1
user3069029
  • 211
  • 2
  • 10

1 Answers1

0

You can try something like:

- (void) awakeFromNib{
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(orientationChanged:)
                                                 name:UIDeviceOrientationDidChangeNotification
                                               object:nil];
}

- (void)orientationChanged:(NSNotification *)notification
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    NSString *deviceType = [UIDevice currentDevice].model;

    if (UIDeviceOrientationIsLandscape(deviceOrientation))
    {
        if ([deviceType rangeOfString:@"iPhone"].location == NSNotFound) {
        }
        else{
        }
    }
    else if (UIDeviceOrientationIsPortrait(deviceOrientation))
    {
        if ([deviceType rangeOfString:@"iPhone"].location == NSNotFound) {
         }
        else{
        }
    }
    else
    {
    }
}
Calin Chitu
  • 1,099
  • 7
  • 13