[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
誰かがあなたのアプリがAppleによって拒否されることを確認できますか?
良い代替品はありますか?
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
誰かがあなたのアプリがAppleによって拒否されることを確認できますか?
良い代替品はありますか?
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientation] はプライベート API であり、署名が読み取り専用であることがわかります (こちらを参照)。
デバイスの向きを縦またはその他のモードに設定する場合は、shouldAutorotateToInterfaceOrientation をオーバーライドする必要があります。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationPortrait);
}
はい、拒否されます。
フレームを変更してキー ウィンドウに変換を適用し、ステータス バーの向き (パブリック) を変更して、向きの変更をシミュレートできます。
このコードを試すことができます。それは私のアプリで完璧に動作します
UIApplication* application = [UIApplication sharedApplication];
if (application.statusBarOrientation != UIInterfaceOrientationPortrait)
{
AppDelegate* app = [[UIApplication sharedApplication] delegate];
UIViewController *c = [[UIViewController alloc]init];
[app.viewController presentModalViewController:c animated:NO];
[app.viewController dismissModalViewControllerAnimated:NO];
[c release];
}
ここで、app.viewControllerはアプリのrootViewControllerです。
アプリの plist に UIInterfaceOrientation を追加できます