Sto utilizzando willRotateToInterfaceOrientation
per scambiare le visualizzazioni quando il mio iPad ruota. Se ho una vista modale o una vista di avviso aperta quando il mio dispositivo ruota e scambia le viste, la vista cambia e l'avviso scompare e non riappare, anche se l'avviso viene "presentato" più tardi.Come posso evitare la scomparsa di una vista modale quando si ruota su iPad?
Modifica: Ho ristretto questo problema un po '. Quando viene presentata una vista modale con UIModalPresentationFullScreen
, la vista modale "sopravvive" alle rotazioni.
Cosa posso fare per risolvere questo problema?
Qui è la mia realizzazione di 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];
}
}
Grazie. Per ora sto lavorando senza scambiare le viste, ma questa non è una soluzione ... – Moshe
Sì, non ho mai riscontrato questo problema, ma semplicemente perché ridimensiono le visualizzazioni solo cambiando l'orientamento, piuttosto che sostituirle . Sarebbe possibile presentare la pagina modale da una vista di hosting trasparente, ma i tuoi contenuti dovrebbero essere in una sottoview di ciò che è stato cambiato nel cambiamento di orientamento? –
@BradLarson - Grazie per dare un'occhiata. Penso che il tuo suggerimento funzionerebbe, ma è leggermente inefficiente, perché devi caricare una vista aggiuntiva (controller). Per ora sto aspettando che Apple risponda a questa domanda e sto ridimensionando manualmente, ecc. Volevo evitarlo perché UIImageViews non si comporta troppo bene. – Moshe