別のビューを作成するために、ユーザーがアプリを起動したときのデバイスの向きを知りたいです。私が奇妙だと思うのは、以下のとおりです。
- (void)viewDidLoad
{
if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
NSLog(@"1");
}
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
NSLog(@"2");
}
if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft) {
NSLog(@"3");
}
if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortraitUpsideDown) {
NSLog(@"4");
}
}
誰も印刷されていません!私はiPadシミュレーターでそれを行いましたが、向きはUIDeviceOrientationPortraitである必要があると思います。なぜこれが起こるのですか?向きを正しく知る方法は?