1

ユーザーが AppDelegate.m ファイルで横向きモードから縦向きモードに切り替えたときにストーリーボードを変更する方法はありますか 別の iOS 用に別の StoryBoards に切り替えるように既に作成しましたが、横向きモードから縦向きモードに切り替えることはできません。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];

                    }

これは可能ですか?

4

1 に答える 1

0

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
于 2012-11-23T14:51:07.897 に答える