これを知らず、単純にIF分で「横向きの場合とそれ以外」と指定していたため、テーブルの上に置いて操作した場合に、画面が横向きにもかかわらず、処理の途中で縦向きの計算をしてしまっていたのだ。
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationUnknown ){
NSLog(@"デバイスの向きが不明");
}else if (orientation == UIDeviceOrientationPortrait ){
NSLog(@"ホームボタンが下にある状態");
}else if (orientation == UIDeviceOrientationPortraitUpsideDown ){
NSLog(@"ホームボタンが上にある状態");
}else if (orientation == UIDeviceOrientationLandscapeLeft ){
NSLog(@"ホームボタンが右にある状態");
}else if (orientation == UIDeviceOrientationLandscapeRight ){
NSLog(@"ホームボタンが左にある状態");
}else if (orientation == UIDeviceOrientationFaceUp ){
NSLog(@"ホームボタンが真上を向いている状態");
}else if (orientation == UIDeviceOrientationFaceDown ){
NSLog(@"ホームボタンが真下を向いている状態");
}
コメントする