アプリの起動時に iPad の向きをプログラムで検出する方法を知っている人はいますか。
私は次のメカニズムを使用しています。
- (void) detectDeviceInitialOrientation
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
MyAppDelegate *appDelegate=(MyAppDelegate*)[[UIApplication sharedApplication] delegate];
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (UIDeviceOrientationIsPortrait(orientation)) {
appDelegate.orintation = PORTRAIT;
}
else if (UIDeviceOrientationIsLandscape(orientation)) {
appDelegate.orintation = LANDSCAPE;
}
}
ただし、デバイスが床と平行に置かれている場合、デバイスの向きを検出できません。だから、私は別の解決策を探しています。助けてください......