0

この質問が重複している場合は申し訳ありませんが、同じ解決策が見つかりません。iOS6 では、1 つの UIViewController のデフォルトの向きを設定する場合は、次を使用します。

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

しかし、iOS5 で同じことを行うには、両方をテストします。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);//not default
}
and
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationMaskLandscapeLeft);// = return NO;
}

しかし、デフォルトの向きは常に Portrait.Any 提案?

4

4 に答える 4

3

orientation.happy コーディングのステータスを確認したい場所で以下のメソッドを呼び出します:-)

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [self CheckForViewForOrientation:toInterfaceOrientation];
}

- (void) CheckForViewForOrientation:(UIInterfaceOrientation)orientation
{
    if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        //Ur lable portrait view
    }
    else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        //Ur lable for landscape view
    }
}
于 2013-01-25T07:19:55.893 に答える
1
- (BOOL)shouldAutorotate {

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation==UIInterfaceOrientationPortrait) {
 // do some 

}

return YES;
}

5 と 6 の両方をサポートするために両方のメソッドを含める

于 2013-01-25T07:20:24.577 に答える
1

アプリケーション全体でこれを実現したい場合は、app.plist ファイルでサポートされている方向 UISupportedInterfaceOrientations を変更してください。

于 2013-01-25T07:14:37.923 に答える
1

提供する必要があります

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

その単一のビューコントローラー用。

于 2013-01-25T07:27:36.307 に答える