【问题标题】:Present modalViewController in Landscape mode using storyboard in IOS 6在 IOS 6 中使用情节提要以横向模式呈现 modalViewController
【发布时间】:2012-10-15 21:13:42
【问题描述】:

我有一个应用程序在纵向模式下有一些视图,我想在横向模式下呈现模态视图控制器...对于 IOS 5.0 和 5.1 完美运行,在 IOS 6 中它打开 modalView 但处于纵向模式。你需要知道:我使用情节提要,并将 VC 设置为 Landscape ...... 在应用委托中我添加了:

-(NSUInteger)application:(UIApplication *)application    supportedInterfaceOrientationsForWindow:(UIWindow *)w
{return UIInterfaceOrientationMaskPortrait;}

如果我添加| UIInterfaceOrientationMaskLandscape,我可以在其他视图中旋转应用程序。

然后对于摘要,我禁用了所有支持的界面方向.. 在这里,我尝试将纵向和横向设置为左,效果很好,但在这种情况下,我可以将所有视图旋转到左并返回到纵向。

在我想在横向午餐的 ViewCONtroller 之后,我有适用于 IOS 6 的以下方法:

-(NSUInteger)supportedInterfaceOrientations
{return UIInterfaceOrientationLandscapeLeft;}

-(BOOL)shouldAutorotate
{return YES;}

当我点击按钮午餐modalView运行后,我得到这个错误:“支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES”

我知道在该方法上返回 YES,但如果我设置 NO,则不会发生任何事情。 我想考虑一下:我的应用需要在 IOS 5 及更高版本上运行。

有人可以帮帮我吗? 任何建议都值得赞赏;)

非常感谢

【问题讨论】:

  • 大家好,我通过添加一个新的导航控制器(在故事板中)来实现它,然后通过这个新的导航控制器呈现模态。希望你能管理好这个。祝你好运;)

标签: ios6 modalviewcontroller landscape


【解决方案1】:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self transformView2ToLandscape];}

-(void) transformView2ToLandscape {

NSInteger rotationDirection;
UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];

if(currentOrientation == UIDeviceOrientationLandscapeLeft){
    rotationDirection = 1;
}else {
    rotationDirection = -1;
}

CGAffineTransform transform = [arController.viewController.view transform];
transform = CGAffineTransformRotate(transform, degreesToRadians(rotationDirection * 90));
[arController.viewController.view setTransform: transform];}

这对我来说很好。

【讨论】:

    猜你喜欢
    • 2012-05-13
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-04
    • 2014-09-23
    • 1970-01-01
    • 2014-06-22
    相关资源
    最近更新 更多