2

私はiPhone用のアプリを書いています。正常に動作しますが、iPad では正しくスケーリングされません。私は横向きのビューを持っており、プログラムでそれを行いました。それから私はプッシュをしています。次に、これを示します。

ここに画像の説明を入力

回転してフルスクリーンにしたい。私を助けてください。前もって感謝します。

4

1 に答える 1

3

次のコードのようにios6またはios5でオリエンテーションを確認して実装できます。情報は各クラスにメソッドを配置します。

-(BOOL)shouldAutorotate
{
    return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{

    return UIInterfaceOrientationMaskAll;
}

ViewWillApearそして、次のようなデバイスの向きで毎回チェックしてください:-

- (void)willRotateToOrientation:(UIInterfaceOrientation)newOrientation {
        if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
        {
            if (newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight) {

              //set your landscap View Frame
                [self supportedInterfaceOrientations];

            }



        }
        else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
        {
            if(newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown){
      //set your Potrait View Frame
                [self supportedInterfaceOrientations];

            }
        }
        // Handle rotation
    }


    -(void)viewWillAppear:(BOOL)animated
    {
        [self willRotateToOrientation:[[UIDevice currentDevice] orientation]];  
        [super viewWillAppear:YES];
    }

アップデート

おそらく人々は、この行を:-orientationに入れる際に、以下のようなチェックデバイスを使用しますViewWillApear

[[UIApplication sharedApplication] statusBarOrientation];
    [[UIDevice currentDevice] orientation];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil];

-(void)deviceRotated:(NSNotification*)notification
{

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        //Do your stuff for landscap
    }
    else if(orientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
    {
      //Do your stuff for potrait

    }

}

IOS5 では、次のように実行できるランドスケープのみ:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {


        return YES;
    }
    else
    {
        return NO;
    }
}

すべてのオリエンテーションをサポートしたい場合は、次のように YES を返す必要があります:-

 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

            return YES;  
    }
于 2013-01-31T09:15:28.487 に答える