haptic guidelines blue ios ipad rotation modal-dialog

guidelines - ios layout



iOS 6: modalPresentationStyle del modal padre ignorado después de la rotación (3)

Con iPad con iOS6, tenemos este error donde un controlador de vista modal se expandirá a pantalla completa, incluso si se dice que está usando el estilo de presentación de "hoja de formulario". Pero esto sucede solo si hay dos modales, uno principal y su hijo.

Así que 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 girar de paisaje a retrato, el modo modal principal se expandirá a pantalla completa y se mantendrá de esa manera incluso si giramos de nuevo a horizontal.

Cuando tenemos el modo principal por sí solo (sin modo hijo), funciona como se esperaba, que es que permanece en el estilo de hoja de formulario.

Tenga en cuenta que esto sucede solo en iOS6 (dispositivo y simulador) y no ocurre en iOS 5 (el simulador informa que los testers lo han probado).

Hasta ahora, he intentado lo siguiente sin éxito:

  • estableciendo wantsFullScreenLayout en NO
  • forzando wantsFullScreenLayout a siempre devolver NO wantsFullScreenLayout
  • UIModalPresentationFormSheet mis controladores dentro del controlador de navegación también especifiquen UIModalPresentationFormSheet
  • implementando preferredInterfaceOrientationForPresentation
  • actualizar a iOS 6.0.1

¡Gracias!

ACTUALIZACIÓN : Entonces, adapté la respuesta de los foros de desarrolladores de Apple ( https://devforums.apple.com/message/748486#748486 ) para que funcione con múltiples 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]; }


Necesita instanciar su controlador de navegación después de su vista principal. Para que pueda administrar la rotación en cada vista.

Si su AppDelegate RootViewController es un controlador de navegación, no podrá administrar la rotación con funciones nativas.


No estoy seguro de si esto se debe considerar como un error y tengo curiosidad de lo que traerá iOS 7, pero la solución actual para este problema es establecer modalPresentationStyle en UIModalPresentationCurrentContext para child-viewController.

Set modalPresentationStyle = UIModalPresentationCurrentContext

Esto hace que el niño todavía se presente como FormSheet, pero evita que el padre cambie de tamaño a pantalla completa en rotación.

Puñal


Puedo ver 2 problemas aquí.

1) en iOS 6, el método presentModalViewController:animated: está en desuso, pruebe a usar presentViewController:animated:completion: (a pesar de que esto podría no ser de ayuda, aún puede querer hacerlo)

2) En iOS 6 de alguna manera parecía que los controladores de contenedor (como UINavigationController ) no UINavigationController los mensajes de autorrotación a sus hijos. Pruebe subclassing UINavigationController y redefina los métodos de autorrotación correspondientes para enviar a todos los niños. Esto podría ayudar.