4

ビューを設定するための現在の向きを検出したいのですが、以下の方法とどのように行うのが良いですか?

[[UIDevice currentDevice]orientation]

[[UIApplication sharedApplication] statusBarOrientation]

4

2 に答える 2

2

[[UIApplication sharedApplication] statusBarOrientation]デバイスの向きを検出するために使用できます 。

このメソッドは、すべてのケースで向きの値を返しますが、

[[UIDevice currentDevice]orientation]

向きがわからないことがあります。

それがうまくいくことを願っています。

于 2013-04-02T05:11:58.503 に答える
0

以下のコードを使用できます。

if (UIInterfaceOrientationIsLandscape([[UIDevice currentDevice] orientation]))
{
     NSLog(@"-Landscape");
}
 else 
{
     NSLog(@"-Portrait");
}
于 2013-04-02T05:42:39.290 に答える