Orientation change issue in iOS6

My application is working fine for iOS5. But for iOS6 I am getting the following orientation problem.

I have a ViewController VC1. when you rotate (change the orientation to UIInterfaceOrientationLandscapeRight) I want to present another ViewController VC2 and when you rotate back I need to dismiss VC2 and the VC1 should be in Portrait mode.

I am using tabBar in my application and I want this feature only for the first tab.

In tabBar I have written

-(BOOL) shouldAutorotate
{
    UINavigationController *nav = (UINavigationController *)self.selectedViewController;
    if ([nav.topViewController isKindOfClass:[MainViewController class]])
    {
        return YES;
    }
    else
    {
        return NO;
    }
} 
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    //Here I am writing code for presenting view(using notifications)
    // but When I rotate the device to landscape it's getting called but when I rotate back 
    //to portrait I not getting called.
}

Thank you.


请使用ios 6试试这个:(例子)

- (BOOL)shouldAutorotate
{
   return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait | UIInterfaceOrientationLandscapeRight | UIInterfaceOrientationLandscapeLeft;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
   return UIInterfaceOrientationLandscapeRight;

}
链接地址: http://www.djcxy.com/p/66332.html

上一篇: Java构造函数赋值给变量,然后交换它们

下一篇: iOS6中的方向更改问题