2013/11/07 カテゴリー:iPhone アプリ開発 タグ:タグ: iPad, iPhone 5s, Objective-C, Xcode

iPhone, iPadの画面の向きを検出する方法整理しました。
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientationで処理できます。
int direction = self.interfaceOrientation;
int direction = self.interfaceOrientation;
if(direction == UIInterfaceOrientationPortrait){
NSLog(@"縦(ホームボタン下)");
}
else if(direction == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"縦(ホームボタン上)");
}
else if(direction == UIInterfaceOrientationLandscapeLeft){
NSLog(@"横(ホームボタン左)");
}
else if(direction == UIInterfaceOrientationLandscapeRight){
NSLog(@"横(ホームボタン右)");
}
«前へ OmniGraffleのテンプレートの設定方法 次へ» 「金持ち父さんの起業する前に読む本 」-ビッグビジネスで成功するための10のレッスン