Je ne vois pas pourquoi j'ai ce problème mais je suis ..... Fondamentalement, j'ai un contrôleur de barre Tabr avec un contrôleur de navigation dans l'un des onglets. Dans cet onglet particulier, je veux que l'utilisateur soit capable de faire pivoter l'appareil et voir une vue complètement différente, pas la vue d'origine tournée! Pour ce faire (en plein écran), j'ai un LandscapeViewController que je présente de manière modale lorsque l'appareil est en mode paysage. Le problème survient lorsque je présente le modalViewController ..... dans le LandscapeViewController, je vérifie également l'orientation pour que je puisse me déconnecter quand l'utilisateur revient en mode portrait. Cependant quand je le présente, je reçois un rappel disant qu'il passe en mode portrait, ce qui le gâche complètement! Voici le code et Consignation des instructions pour clarifier ce qui est goin ..Problèmes de rotation de ModalViewController dans TabBarController
//in PortraitViewContoller
(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"Norm going Portrait");
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
NSLog(@"Norm going Landscape");
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
(void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:5.];
if(portrait){
NSLog(@"dismissed");
[self dismissModalViewControllerAnimated:NO];
}
else{
NSLog(@"presented");
LandscapeOverviewViewController *land = [[LandscapeOverviewViewController alloc]initWithNibName:@"LandscapeOverviewViewController" bundle:nil];
land.delegate = self;
[self presentModalViewController:land animated:NO];
[land release];
}
[UIView commitAnimations];
}
//in LandscapeViewController
(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){
NSLog(@"Modal is going Portrait");
[self changeTheViewToPortrait:YES andDuration:duration];
}
else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft){
NSLog(@"Modal is going Landscape");
[self changeTheViewToPortrait:NO andDuration:duration];
}
}
(void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
if(portrait){
NSLog(@"calling delegate to dismiss");
[delegate landscapeViewController:self didRotateBack:(YES)];
}
[UIView commitAnimations];
}
et c'est le texte du journal
Norm va Paysage
2010-08-24 15: 29: 40,024 App [ 32461: 207] présenté
2010-08-24 15: 29: 40,026 App [32461: 207] Modal est en cours Portrait
2010-08-24 15: 29: 40,026 App [32461: 207] calli délégué ng à rejeter
2010-08-24 15: 29: 40,027 App [32461: 207] délégué a
Comme vous pouvez le voir quand en mode portrait et je ne le faire pivoter la chose correcte en présentant le landscapevc, mais alors il pense que c'est en portrait et essaie de rejeter? Est-ce que quelqu'un peut voir où je vais mal, et apoligies pour la durée de cette mais le formatage du code ne fonctionnerait pas correctement sinon.
Un grand merci
Jules
Merci pour la réponse, oui j'avais implémenté shouldAutorotateToInterfaceOrientation :. À la fin, j'ai mis au rebut en utilisant l'autorotate et juste fait cela dans le viewController relelvant. [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; \t [[NSNotificationCenter defaultCenter] addObserver: auto-sélecteur: @selector (detectOrientation) nom: @ "UIDeviceOrientationDidChangeNotification" objet: nil]; et tourné si nécessaire. Merci beaucoup Jules – Jules