ビューを設定するための現在の向きを検出したいのですが、以下の方法とどのように行うのが良いですか?
[[UIDevice currentDevice]orientation]
[[UIApplication sharedApplication] statusBarOrientation]
[[UIApplication sharedApplication] statusBarOrientation]
デバイスの向きを検出するために使用できます 。
このメソッドは、すべてのケースで向きの値を返しますが、
[[UIDevice currentDevice]orientation]
向きがわからないことがあります。
それがうまくいくことを願っています。
以下のコードを使用できます。
if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
{
NSLog(@"-Landscape");
}
else
{
NSLog(@"-Portrait");
}