视图控制器在iOS 7中不旋转

Mar*_*uti 5 objective-c uiviewcontroller ios ios7

我的应用程序在ios 6中工作正常.但是当我将我的应用程序升级到ios 7时,视图控制器没有旋转.我已将rootviewcontroller设置为mainviewcontroller.self.window.rootViewController = mainViewcontroller; ios 7中的哪些变化使我的应用程序无法旋转..?

aja*_*jay 1

这是我在 xcode 4.6 和 xcode5-DP6 中测试过的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
    } else {
        self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
    }
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController];

    self.window.rootViewController = navigationController;//self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

在 ViewController 中我插入了以下测试方法

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    NSLog(@"rotated");
}
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码,旋转没有任何问题。它在各个方向上完美旋转。

检查您的定位方法以克服此问题或发布一些代码片段。

注意:我在 Xcode4.6 中创建了示例应用程序。