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

时间:2013-09-16 03:41:13

标签: ios objective-c uiviewcontroller ios7

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

1 个答案:

答案 0 :(得分: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;
}

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

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
    NSLog(@"rotated");
}

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

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

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