LoginSignup
1
3

More than 3 years have passed since last update.

Swiftのorientationの参考記事まとめ

Last updated at Posted at 2019-06-24

参考記事

[iOS] デバイスの向きとアプリの向き
iOS でデバイスの向きを取得するときの罠
【Swift】UIDevice | ポケットリファレンス サンプル付き
iOS 画面の回転状態を調べる-2012年更新
iOSでの動画処理における「回転」「向き」の取り扱いでもう混乱したくない

個人的な参考部分

【Swift】UIDevice | ポケットリファレンス サンプル付き

// 表示されている画面の向きを取得します。例:UIDeviceOrientation
print(UIDevice.currentDevice().orientation)

iOS 画面の回転状態を調べる-2012年更新
unknownはシミュレーターだと、横向きにした状態で、XCodeからアプリケーションをRunした場合等になる。
しかし、unknownが返っている場合でもシステム側は現在の向きを保持していて、アプリケーションを立ち上げた時には、ステータスバー等は画面の向きに正しい方向に表示され、アプリケーション内にAutosizingで配置してあるボタン等も画面の向きに合わせて正しく配置される。
なので、少なくともアプリケーションはunknownの場合でも画面の表示する向きは少なくとも知っている。
.....
画面関連のレイアウトで4方向のみを確実に調べる時は、これを使用する。

UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3