1

方向在 presentViewController 中不起作用。甚至正在使用 UINavigationController 的类别。调用了supportedInterfaceOrientations 方法,但没有更改。在基本视图控制器中,shouldAutorotate 方法返回 YES。哪里有以下代码。

我正在使用此代码。

ViewControllerOne *viewOne = [[ViewControllerOne alloc]init];

UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:viewOne];
navCtrl.modalPresentationStyle = UIModalPresentationFormSheet;

[self presentViewController:navCtrl animated:YES completion:nil];

请帮我。提前致谢...

4

1 回答 1

1

您使用的是哪个模拟器 ios 5 或 ios 6?再贴一些代码。另请参阅此链接。

替换了 appDelegate 中的这一行代码:

[window addSubview:viewController.view];

通过这一行:

[window setRootViewController:viewController];

检查 iOS 5 和 6

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)])
        {
            [self presentViewController:navigationControllerCustom animated:YES completion:nil];
        }
        else
        {
            [self presentModalViewController:navigationControllerCustom animated:YES];
        }

尝试使用旋转

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
于 2012-12-05T09:06:31.130 回答