2011-09-16 7 views
2

可能性の重複:
iPhone orientationUIViewで向きを確認する方法は?

私はUIViewのの向き(その風景やポートレートモードかどうか)を確認したいです。

どうすればいいですか?

+0

「iPhone Check Orientation」の簡単な検索結果が表示されます。投稿する前にまず検索してみてください。 –

答えて

0

UIViewは、方向性がありません。 またはUIApplicationStatusBarの向きを確認できます

7

UIViewオリエンテーションプロパティがありません。あなたがこれを使って好きな場所

あなたは、現在のデバイスの向きを確認することができます。

UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation; 
    if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown) { 
     //portrait 
    } 
    else { 
     //landscape 
    } 
+0

UIInterfaceOrientationではありません。そのUIDeviceOrientation。そして、それは風景やポートレートモードをチェックしません。 :( – Devang

0

@interface YourView : UIView<UIAccelerometerDelegate>としてあなたのクラスで(私はあなたがUIViewをサブクラス化していることを仮定している)、その後-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration方法でUIAccelerometerDelegateを実装し、値がacceleration.xであることを確認してください。 1または-1に近い場合、デバイスは左右に横向きに保持されます。 acceleration.yをチェックして縦向きを確認する

関連する問題