SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
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
おわり

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (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)
 

Kürzlich hochgeladen

Kürzlich hochgeladen (10)

論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 

iOS 6 のAuto Rotation