Estoy usando willRotateToInterfaceOrientation
para intercambiar vistas cuando mi iPad gira. Si tengo una vista modal o una vista de alerta abierta cuando mi dispositivo gira e intercambia las vistas, la vista se intercambia y la alerta desaparece y no vuelve a aparecer, incluso si la alerta se "presenta" nuevamente más adelante.¿Cómo evito que desaparezca una vista modal al girar en el iPad?
Editar: He reducido este problema un poco. Cuando se presenta una vista modal con UIModalPresentationFullScreen
, la vista modal "sobrevive" a las rotaciones.
¿Qué puedo hacer para solucionarlo?
Aquí es mi implementación de willRotateToInterfaceOrientation
:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
//
// Load an alternate view depending on the orientation
//
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
[UIView beginAnimations:@"" context:nil];
[self setView:theLandscapeView];
self.view.bounds = CGRectMake(0, 0, 1024, 768);
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (-90));
[UIView commitAnimations];
}else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[UIView beginAnimations:@"" context:nil];
[self setView:theLandscapeView];
self.view.bounds = CGRectMake(0, 0, 1024, 768);
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (90));
[UIView commitAnimations];
}else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
[UIView beginAnimations:@"" context:nil];
[self setView:thePortraitView];
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (0));
self.view.bounds = CGRectMake(0, 0, 768, 1024);
[UIView commitAnimations];
}else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[UIView beginAnimations:@"" context:nil];
[self setView:thePortraitView];
self.view.transform = CGAffineTransformMakeRotation(kDegreesToRadians * (180));
self.view.bounds = CGRectMake(0, 0, 768, 1024);
[UIView commitAnimations];
}
}
Gracias. Por ahora estoy trabajando sin intercambiar puntos de vista, pero eso no es una solución ... – Moshe
Sí, nunca he encontrado este problema, pero eso es simplemente porque solo cambio el tamaño de las vistas para cambiar la orientación, en lugar de reemplazarlas . ¿Sería posible presentar la página modal desde una vista de alojamiento transparente, pero su contenido debe estar en una subvista de lo que se cambia al cambiar de orientación? –
@BradLarson - Gracias por echar un vistazo. Creo que su sugerencia funcionaría, pero es un poco ineficiente, porque necesita cargar una vista adicional (controlador). Por ahora estoy esperando que Apple responda a esta pregunta y estoy redimensionando manualmente, etc. Quería evitar eso porque UIImageViews no lo considera demasiado bien. – Moshe