iOS 6: modalPresentationStyle modal de los padres ignorado después de la rotación
Con iPad con iOS6, tenemos este error donde un controlador de vista modal se expandirá a pantalla completa, incluso si se le indica que use el estilo de presentación "hoja de formulario". Pero, esto sucede solo si hay dos modales, uno padre y su hijo.
Así es como se crea y presenta el primer modal:
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is my application's root controller
Así es como se crea y presenta el modal infantil:
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[parentController presentModalViewController:navigationController animated:YES];
// parentController is the navigationController from above
Por lo tanto, al rotar de horizontal a vertical, el modal principal se expandirá a pantalla completa y seguirá siendo así, incluso si giramos de nuevo a horizontal.
Cuando tenemos el modo principal todo por sí mismo (sin modo secundario), entonces funciona como se esperaba, es decir, permanece en el estilo de hoja de formulario.
Tenga en cuenta que esto ocurre solo en iOS6 (dispositivo y simulador) y no ocurre en iOS 5 (simulador y se informa que los probadores funcionan).
Hasta ahora, he intentado lo siguiente sin éxito:
ajustewantsFullScreenLayout
aNO
forzandowantsFullScreenLayout
para volver siempreNO
por anularloAsegurarme de que mis controladores dentro del controlador de navegación también especificanUIModalPresentationFormSheet
implementarpreferredInterfaceOrientationForPresentation
actualizar a iOS 6.0.1¡Gracias!
ACTUALIZAR: Entonces, adapté la respuesta de los foros de desarrolladores de Apple (https://devforums.apple.com/message/748486#748486) para que funcione con multiples modos anidados.
- (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];
}