iPhone デバイスがフラットであることを検出する
-
21-09-2019 - |
質問
写真を撮るときに携帯電話の向きを検出するために使用します
orientation == UIDeviceOrientationLandscapeRight
orientation == UIDeviceOrientationPortraitUpsideDown
orientation == UIDeviceOrientationPortrait
orientation == UIDeviceOrientationLandscapeLeft
ただし、これらは写真を横から撮影している場合に機能します。iPhone が下に傾いて平らになっているかどうかを確認するにはどうすればよいですか。航空写真を撮るときは?
解決
デバイスの向きには他の定数も存在します。
typedef enum {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait,
UIDeviceOrientationPortraitUpsideDown,
UIDeviceOrientationLandscapeLeft,
UIDeviceOrientationLandscapeRight,
UIDeviceOrientationFaceUp,
UIDeviceOrientationFaceDown
} UIDeviceOrientation;
それらはここで見つけることができます: UIDevice クラスのリファレンス
他のヒント
生をグラフ http://developer.apple.com/iphone の上のサンプルアプリがあります加速度計からのデータ。お使いのデバイス上でそれをインストールし、あなたが得るデータの種類を見ています。
サンプルアプリが効果的に重力を相殺するオプション(私はそれが「ダンピング」だと思う)が付属しています。あなたはこれを行うにはしたくない - 実際には重力が、それはフラットだとき、Z軸でお使いのデバイスを「加速」...
に何が起こっているのです所属していません StackOverflow