iOS6 を搭載した iPad では、「フォーム シート」プレゼンテーション スタイルを使用するように指示されていても、モーダル ビュー コントローラーが全画面表示になるというこのバグがあります。ただし、これは、親モーダルとその子モーダルの 2 つのモーダルがある場合にのみ発生します。
したがって、これが最初のモーダルの作成方法と表示方法です。
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is my application's root controller
これは、子モーダルを作成して表示する方法です。
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is the navigationController from above
したがって、横向きから縦向きに回転すると、親モーダルはフルスクリーンに拡大され、横向きに戻ってもそのままです。
親モーダルがすべて単独である場合 (子モーダルがない場合)、期待どおりに機能します。つまり、フォーム シート スタイルのままです。
これは iOS6 (デバイスとシミュレーター) でのみ発生し、iOS 5 (シミュレーターであり、テスターによって動作することが報告されています) では発生しないことに注意してください。
これまでのところ、成功せずに次のことを試しました。
wantsFullScreenLayout
に設定NO
- オーバーライドし
wantsFullScreenLayout
て常に強制的に返すNO
- ナビゲーションコントローラー内の特定のコントローラーを指定することも指定します
UIModalPresentationFormSheet
- 実装する
preferredInterfaceOrientationForPresentation
- iOS 6.0.1 へのアップグレード
ありがとう!
更新: したがって、複数のネストされたモーダルで動作するように、Apple Developer Forums ( https://devforums.apple.com/message/748486#748486 ) からの応答を調整しました。
- (BOOL) needNestedModalHack {
return [UIDevice currentDevice].systemVersion.floatValue >= 6;
}
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
// We are the top modal, make to sure that parent modals use our size
if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
for (UIViewController* parent = self.presentingViewController;
parent.presentingViewController;
parent = parent.presentingViewController) {
parent.view.superview.frame = parent.presentedViewController.view.superview.frame;
}
}
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
// We are the top modal, make to sure that parent modals are hidden during transition
if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
for (UIViewController* parent = self.presentingViewController;
parent.presentingViewController;
parent = parent.presentingViewController) {
parent.view.superview.hidden = YES;
}
}
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
// We are the top modal, make to sure that parent modals are shown after animation
if (self.needNestedModalHack && self.presentedViewController == nil && self.presentingViewController) {
for (UIViewController* parent = self.presentingViewController;
parent.presentingViewController;
parent = parent.presentingViewController) {
parent.view.superview.hidden = NO;
}
}
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}