supportedInterfaceOrientations
iOS6から画面の回転に関する処理が変わりました。
ViewControllerに2つのメソッド、
(BOOL)shouldAutorotate
(NSUInteger)supportedInterfaceOrientations
を追加します。
これらのメソッドの大まかな説明は省きます。
この(NSUInteger)supportedInterfaceOrientationsの戻り値ですが、
UIInterfaceOrientationMaskPortraitのような
〜Mask〜
というものを指定します。
これは各ビットがそれぞれの方向に対応しており、どの方向に対応するかを一つの変数で表せます。
Portrait基本形のみ対応する場合でもUIInterfaceOrientationMaskPortraitというMask付きのものを指定します。単一指定ならMaskがついてなくても値は同じだろうと早とちりしてしまいUIInterfaceOrientationPortrait(Maskが付かないやつ)を指定してしまうと、
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
という実行時エラーが出ます。
定義を調べると以下のようになっています。
typedefが少し独特ですが、どこかで#defineされているんでしょう。
typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down
};
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
};
typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) {
UIInterfaceOrientationMaskPortrait =
(1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft =
(1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight =
(1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown =
(1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape =
(UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
};
UIInterfaceOrientationPortrait(Maskが付かないやつ)を返してしまうとここに載ってないので呼び出し側で処理出来ないなどの問題になりそうです。最小ビットのみONは上のリストに載ってないので。
これらによると
UIInterfaceOrientationLandscapeLeftは逆さまのみの対応
UIInterfaceOrientationLandscapeRightは縦基本形のみ対応
になりそうです。意味のあるビットがONならば最小ビットを無視出来る仕様であれば。
ViewControllerに2つのメソッド、
(BOOL)shouldAutorotate
(NSUInteger)supportedInterfaceOrientations
を追加します。
これらのメソッドの大まかな説明は省きます。
この(NSUInteger)supportedInterfaceOrientationsの戻り値ですが、
UIInterfaceOrientationMaskPortraitのような
〜Mask〜
というものを指定します。
これは各ビットがそれぞれの方向に対応しており、どの方向に対応するかを一つの変数で表せます。
Portrait基本形のみ対応する場合でもUIInterfaceOrientationMaskPortraitというMask付きのものを指定します。単一指定ならMaskがついてなくても値は同じだろうと早とちりしてしまいUIInterfaceOrientationPortrait(Maskが付かないやつ)を指定してしまうと、
Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES
という実行時エラーが出ます。
定義を調べると以下のようになっています。
typedefが少し独特ですが、どこかで#defineされているんでしょう。
typedef NS_ENUM(NSInteger, UIDeviceOrientation) {
UIDeviceOrientationUnknown,
UIDeviceOrientationPortrait, // Device oriented vertically, home button on the bottom
UIDeviceOrientationPortraitUpsideDown, // Device oriented vertically, home button on the top
UIDeviceOrientationLandscapeLeft, // Device oriented horizontally, home button on the right
UIDeviceOrientationLandscapeRight, // Device oriented horizontally, home button on the left
UIDeviceOrientationFaceUp, // Device oriented flat, face up
UIDeviceOrientationFaceDown // Device oriented flat, face down
};
typedef NS_ENUM(NSInteger, UIInterfaceOrientation) {
UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,
UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft
};
typedef NS_OPTIONS(NSUInteger, UIInterfaceOrientationMask) {
UIInterfaceOrientationMaskPortrait =
(1 << UIInterfaceOrientationPortrait),
UIInterfaceOrientationMaskLandscapeLeft =
(1 << UIInterfaceOrientationLandscapeLeft),
UIInterfaceOrientationMaskLandscapeRight =
(1 << UIInterfaceOrientationLandscapeRight),
UIInterfaceOrientationMaskPortraitUpsideDown =
(1 << UIInterfaceOrientationPortraitUpsideDown),
UIInterfaceOrientationMaskLandscape =
(UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
UIInterfaceOrientationMaskAll =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown),
UIInterfaceOrientationMaskAllButUpsideDown =
(UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight),
};
UIInterfaceOrientationPortrait(Maskが付かないやつ)を返してしまうとここに載ってないので呼び出し側で処理出来ないなどの問題になりそうです。最小ビットのみONは上のリストに載ってないので。
これらによると
UIInterfaceOrientationLandscapeLeftは逆さまのみの対応
UIInterfaceOrientationLandscapeRightは縦基本形のみ対応
になりそうです。意味のあるビットがONならば最小ビットを無視出来る仕様であれば。
コメント
コメントを投稿