通过拆分视图控制器启动的模态视图问题 [英] Problems with modal view launched over a split view controller

查看:68
本文介绍了通过拆分视图控制器启动的模态视图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个以模式视图启动页面开头的拆分视图应用程序.问题在于,即使ipad处于横向,模态视图也始终以纵向模式启动.如果我旋转ipad几次,它会适当旋转.我已经在Info.plist中设置了UIInterfaceOrientation,但是没有任何影响.

I have created a split view application that begins with a modal view splash page. The problem is that the modal view always launches in portrait mode, even if the ipad is in landscape. If I rotate the ipad a couple of times, it rotates appropriately. I have set UIInterfaceOrientation in my Info.plist, but it doesn't have any impace.

didFinishLaunchingWithOptions 中,我正在使用以下代码

in didFinishLaunchingWithOptions, I am using the following code

...
[self.window addSubview:splitViewController.view];
SplashViewController *modalView = [[SplashViewController alloc] intiWithNibName:nil bundle:nil];
modalView.modalPresentationStyle = UIModalPresentationFullScreen;
[splitViewController presentModalViewController:modalView animated:YES];
...

关于如何确保模式视图在横向启动的任何建议?

Any suggestions on how I can ensure the modal view launches in landscape?

推荐答案

我认为这是更好的方法:

I think this is the better way to do it:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation==UIInterfaceOrientationLandscapeRight) {
        return YES;
    }
    return NO;
}

这篇关于通过拆分视图控制器启动的模态视图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆