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];