【问题标题】:Change Storyboard when switching to Landscape切换到横向时更改情节提要
【发布时间】:2012-11-11 22:11:10
【问题描述】:

当用户在 AppDelegate.m 文件中切换到横向模式到纵向模式时,有没有办法更改情节提要一个名为iPadios5landscape 的情节提要,我正在使用此方法mainStoryboard = [UIStoryboard storyboardWithName:@"iPadios5landscape" bundle:nil]; 切换到情节提要,但我不知道检测方向的方法。并且重要的是把它放在这段代码中

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")==NO)
    {

            if (iOSDeviceScreenSize.height == 480)
            {

                mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_ios5" bundle:nil];
            }

            if (iOSDeviceScreenSize.height == 1024)
{
    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if(orientation == 0) //Default orientation
        //UI is in Default (Portrait) -- this is really a just a failsafe.
        mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad_ios5" bundle:nil];

        else if(orientation == UIInterfaceOrientationPortrait)
            //Do something if the orientation is in Portrait
            mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad_ios5" bundle:nil];

            else if(orientation == UIInterfaceOrientationLandscapeLeft)
                // Do something if Left
                mainStoryboard = [UIStoryboard storyboardWithName:@"iPadios5landscape" bundle:nil];

                else if(orientation == UIInterfaceOrientationLandscapeRight)
                    //Do something if right
                    mainStoryboard = [UIStoryboard storyboardWithName:@"iPadios5landscape" bundle:nil];

                    }

这可能吗?

【问题讨论】:

    标签: xcode ipad orientation


    【解决方案1】:

    将其粘贴在那里以检测方向,然后在 deviceOrientation 是横向或纵向时设置情节提要

     UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    if(orientation == 0) //Default orientation 
        //UI is in Default (Portrait) -- this is really a just a failsafe. 
     else if(orientation == UIInterfaceOrientationPortrait)
        //Do something if the orientation is in Portrait
    else if(orientation == UIInterfaceOrientationLandscapeLeft)
        // Do something if Left
    else if(orientation == UIInterfaceOrientationLandscapeRight)
        //Do something if right
    

    【讨论】:

    • 我使用了您的代码并将其与我的代码混合在一起,请在我的问题中查看它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 2014-11-18
    • 2012-02-03
    • 2011-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多