SlideShare a Scribd company logo
1 of 46
Download to read offline
iOS 6 のAuto Rotation
2012.12.01
ふじしげ ゆういち
@nakiwo
• ふじしげ ゆういち
• @nakiwo
• 株式会社フィードテイラー
http://feedtailor.jp/
Book+
そら案内
Slidrs
• ふじしげ ゆういち
• @nakiwo
• http://www.nakiwo.com/
洞窟物語
めがね
(Mac AppStore)
今日のテーマ
•iOS 6でのUIViewController Auto
Rotation
•iOS 6で仕様が大幅変更
•iOS 6での仕様を把握する
iOS 5
UIViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
By default, this method returns YES for the
UIInterfaceOrientationPortrait orientation only.
iOS 6
UIViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
By default, this method returns YES for the
UIInterfaceOrientationPortrait orientation only.
•deprecated
•呼ばれません
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
誰が正解?
UIInterfaceOrientationMask
typedef enum {
UIInterfaceOrientationMaskPortrait,
UIInterfaceOrientationMaskLandscapeLeft,
UIInterfaceOrientationMaskLandscapeRight,
UIInterfaceOrientationMaskPortraitUpsideDown,
UIInterfaceOrientationMaskLandscape,
UIInterfaceOrientationMaskAll,
UIInterfaceOrientationMaskAllButUpsideDown,
} UIInterfaceOrientationMask;
※ビットマスク
関係者
UIApplication UIViewController
関係者
UIApplication UIViewController
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
bit
and
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
bit
and
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
bit
and
対応回転方向決定
関係者
UIApplication
UIInterfaceOrientationMask
UIApplication
UIApplicationDelegate
- (NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window
上記メソッド未実装の時は次のメソッドが呼ばれる
UIApplication
- (NSUInteger)supportedInterfaceOrientationsForWindow:
(UIWindow *)window
UIApplication
- (NSUInteger)supportedInterfaceOrientationsForWindow:
(UIWindow *)window
The default implementation of this method returns the app’s
default set of supported interface orientations, as defined in
the UIInterfaceOrientation key of the Info.plist file.
If the file does not contain that key, this method returns all
interface orientations for the iPad idiom and returns all
interface orientations except the portrait upside-down
orientation for the iPhone idiom.
UIApplication
- (NSUInteger)supportedInterfaceOrientationsForWindow:
(UIWindow *)window
The default implementation of this method returns the app’s
default set of supported interface orientations, as defined in
the UIInterfaceOrientation key of the Info.plist file.
If the file does not contain that key, this method returns all
interface orientations for the iPad idiom and returns all
interface orientations except the portrait upside-down
orientation for the iPhone idiom.
Info.plistに
UISupportedInterfaceOri
entations有
UISupportedInterfaceOrientationsの値
Info.plistに
UISupportedInterfaceOri
entations無
iPhone
UIInterfaceOrientationMaskAllButUpsideDown
iPad
UIInterfaceOrientationMaskAll
関係者
UIApplication UIViewController
UIInterfaceOrientationMask UIInterfaceOrientationMask
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
bit
and
対応回転方向決定
UIViewController
UIInterfaceOrientationMask
window.rootViewController または
トップのpresentedViewController(モーダル)
UIViewController
- (BOOL)shouldAutorotate
AuroRotateするかどうか(default=YES)
- (NSUInteger)supportedInterfaceOrientations
default
iPhone UIInterfaceOrientationMaskAllButUpsideDown
iPad UIInterfaceOrientationMaskAll
UIViewController
注意点
UIViewController
UIViewController
UIViewController
UIViewController
UIViewController
注意点
UIViewController
UIViewController
UIViewController
UIViewController
聴かれるのは一番親だけ (水色)
UIViewController (UINavigationController,UITabBarController)
注意点
UIViewController
UIViewController
UIViewController
UIViewController
Tips
iOS 5でPortrait専用
だったのにiOS 6で回転してしまう...
iOS 5でPortrait専用
だったのにiOS 6で回転してしまう...
UIApplicationDelegate
- (NSUInteger)application:(UIApplication *)application
supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
Navigationの子で
shouldAutorotateToInterfaceOrientationを
使っていたが呼ばれない....
Navigationの子で
shouldAutorotateToInterfaceOrientationを
使っていたが呼ばれない....
UINavigationControllerのサブクラスを作って...
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger supportedInterfaceOrientations;
= [self.topViewController supportedInterfaceOrientations];
return supportedInterfaceOrientations;
}
iOS 5もサポートしないと...
iOS 5もサポートしないと...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// 今まで通りに書く
return ...;
}
- (NSUInteger)supportedInterfaceOrientations
{
NSUInteger supportedInterfaceOrientations = 0;
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait])
supportedInterfaceOrientations |= UIInterfaceOrientationMaskPortrait;
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown])
supportedInterfaceOrientations |= UIInterfaceOrientationMaskPortraitUpsideDown;
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft])
supportedInterfaceOrientations |= UIInterfaceOrientationMaskLandscapeLeft;
if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight])
supportedInterfaceOrientations |= UIInterfaceOrientationMaskLandscapeRight;
return supportedInterfaceOrientations;
}
おまけ
おまけ
• 複数法対応のViewControllerをモーダルで出す
時、初期方向を変えたい
• 例:動画プレイヤー
縦横対応しているが、初期では横にしたい。
おまけ
• 複数法対応のViewControllerをモーダルで出す
時、初期方向を変えたい
• 例:動画プレイヤー
縦横対応しているが、初期では横にしたい。
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
•View Controller Programming
Guide for iOS
> Supporting Multiple Interface
Orientations
おわり

More Related Content

Viewers also liked

var RAC3 = ReactiveCocoa + Swift
var RAC3 = ReactiveCocoa + Swiftvar RAC3 = ReactiveCocoa + Swift
var RAC3 = ReactiveCocoa + SwiftSyo Ikeda
 
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18Syo Ikeda
 
How to handle bitcode
How to handle bitcodeHow to handle bitcode
How to handle bitcodeSyo Ikeda
 
Himotoki: A type-safe JSON decoding library #関モバ
Himotoki: A type-safe JSON decoding library #関モバHimotoki: A type-safe JSON decoding library #関モバ
Himotoki: A type-safe JSON decoding library #関モバSyo Ikeda
 
ObjectMapperでJSONマッピング
ObjectMapperでJSONマッピングObjectMapperでJSONマッピング
ObjectMapperでJSONマッピングSyo Ikeda
 
SwiftでAndroidアプリ書けるってよ
SwiftでAndroidアプリ書けるってよSwiftでAndroidアプリ書けるってよ
SwiftでAndroidアプリ書けるってよSyo Ikeda
 
iOSでのFramework導入のおさらい #関モバ
iOSでのFramework導入のおさらい #関モバiOSでのFramework導入のおさらい #関モバ
iOSでのFramework導入のおさらい #関モバSyo Ikeda
 
Carthageについて知りたいn個のこと
Carthageについて知りたいn個のことCarthageについて知りたいn個のこと
Carthageについて知りたいn個のことSyo Ikeda
 
Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Natasha Murashev
 

Viewers also liked (12)

var RAC3 = ReactiveCocoa + Swift
var RAC3 = ReactiveCocoa + Swiftvar RAC3 = ReactiveCocoa + Swift
var RAC3 = ReactiveCocoa + Swift
 
Auto Layout の小技
Auto Layout の小技Auto Layout の小技
Auto Layout の小技
 
SwiftLint
SwiftLintSwiftLint
SwiftLint
 
iOSのFileProtection
iOSのFileProtectioniOSのFileProtection
iOSのFileProtection
 
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18
var RAC3 = ReactiveCocoa + Swift @ ReactiveCocoa Tokyo #rac_tokyo 10/18
 
How to handle bitcode
How to handle bitcodeHow to handle bitcode
How to handle bitcode
 
Himotoki: A type-safe JSON decoding library #関モバ
Himotoki: A type-safe JSON decoding library #関モバHimotoki: A type-safe JSON decoding library #関モバ
Himotoki: A type-safe JSON decoding library #関モバ
 
ObjectMapperでJSONマッピング
ObjectMapperでJSONマッピングObjectMapperでJSONマッピング
ObjectMapperでJSONマッピング
 
SwiftでAndroidアプリ書けるってよ
SwiftでAndroidアプリ書けるってよSwiftでAndroidアプリ書けるってよ
SwiftでAndroidアプリ書けるってよ
 
iOSでのFramework導入のおさらい #関モバ
iOSでのFramework導入のおさらい #関モバiOSでのFramework導入のおさらい #関モバ
iOSでのFramework導入のおさらい #関モバ
 
Carthageについて知りたいn個のこと
Carthageについて知りたいn個のことCarthageについて知りたいn個のこと
Carthageについて知りたいn個のこと
 
Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)Protocol-Oriented MVVM (extended edition)
Protocol-Oriented MVVM (extended edition)
 

Recently uploaded

自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineerYuki Kikuchi
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfFumieNakayama
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)Hiroshi Tomioka
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案sugiuralab
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)UEHARA, Tetsutaro
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?akihisamiyanaga1
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfFumieNakayama
 

Recently uploaded (8)

自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
自分史上一番早い2024振り返り〜コロナ後、仕事は通常ペースに戻ったか〜 by IoT fullstack engineer
 
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdfクラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
クラウドネイティブなサーバー仮想化基盤 - OpenShift Virtualization.pdf
 
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
TataPixel: 畳の異方性を利用した切り替え可能なディスプレイの提案
 
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
デジタル・フォレンジックの最新動向(2024年4月27日情洛会総会特別講演スライド)
 
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
CTO, VPoE, テックリードなどリーダーポジションに登用したくなるのはどんな人材か?
 
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdfAWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
AWS の OpenShift サービス (ROSA) を使った OpenShift Virtualizationの始め方.pdf
 

iOS 6 のAuto Rotation