【问题标题】:ios 6 presentViewControllerios 6 呈现视图控制器
【发布时间】:2012-11-21 07:59:10
【问题描述】:

方向在 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];

请帮助我。提前谢谢...

【问题讨论】:

标签: ios6


【解决方案1】:

您使用的是哪个模拟器 ios 5 或 ios 6? 再贴一些代码。 另见link.

在 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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-15
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    相关资源
    最近更新 更多