2017-07-14 12 views
1

ios10では、setStatusBarOrientationは推奨されていません。古いプロジェクトコードのスニペットはうまく動作しません。どのようにそれらを解決するのですか? - UITraitCollectionとサイズクラスの使用をサポートするために廃止されました[のUIApplication statusBarOrientation]setStatusBarOrientationは推奨されていません.ios10でデバイスの向きを変更する方法

float angle; 
CGRect rect; 
// UIInterfaceOrientation orientation; 
    float fWidth = _viewController.view.bounds.size.width; 
    float fHeight = _viewController.view.bounds.size.height; 
    float fMaxValue = (fWidth > fHeight) ? fWidth : fHeight; 
    float fMinValue = (fWidth > fHeight) ? fHeight : fWidth; 

    if ((eScreenOrientation)ore == eScreenOrientation::Landscape) { 
     if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) { 
//   orientation = UIInterfaceOrientationLandscapeRight; 
      angle = M_PI_2; 
     } else { 
//   orientation = UIInterfaceOrientationLandscapeLeft; 
      angle = -M_PI_2; 
     } 
     rect = CGRectMake(0, 0, fMaxValue, fMinValue); 
    } else { 
//  orientation = UIInterfaceOrientationPortrait; 
     angle = 0; 
     rect = CGRectMake(0, 0, fMinValue, fMaxValue); 
    } 

// [[UIApplication sharedApplication] setStatusBarOrientation: orientation]; 
    _viewController.view.transform = CGAffineTransformMakeRotation(angle); 
    _viewController.view.bounds = rect; 
    [_viewController resetViewSize]; 

答えて

1

それが信じられることです。私たちが望むよう次のコードは、ViewControllerをを変更します。アップルのドキュメントからも

@property(読み取り専用、非アトミック)UIInterfaceOrientation statusBarOrientation __TVOS_PROHIBITED。

//ステータスバーの向きの明示的な設定は、iOS 6.0以降ではより限定されています。 UIInterfaceOrientation statusBarOrientation NS_DEPRECATED_IOS(2_0,9_0、 "ステータスバーの向きの明示的な設定は、iOS 6.0以降では制限されています")__TVOS_PROHIBITED;

上記のコードを同じ目的で使用することはできないようです。

このリンクはお役に立ちますLink to orientation

関連する問題