我想知道用戶啓動我的應用時的設備方向,以便產生不同的視圖。我覺得奇怪的是如下:如何正確知道設備方向
- (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。爲什麼會發生?以及如何正確地知道方向?
http://stackoverflow.com/questions/5888016/ios-device-orientation-on-load –
http://stackoverflow.com/questions/634745/iphone-orientation –