2012-08-09 5 views
1

Dans mon rootViewController, j'ai ré-implémenté la méthode shouldAutorotateToInterfaceOrientation comme ceci.Méthode ios dev - shouldAutorotateToInterfaceOrientation non appelée pour le mode portrait

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { 
    switch (toInterfaceOrientation) { 
     case UIInterfaceOrientationPortrait: 
      NSLog(@"Orientation - Portrait"); 
      break; 
     case UIInterfaceOrientationLandscapeLeft:   
      NSLog(@"Orientation - Left"); 
      break; 
     case UIInterfaceOrientationLandscapeRight: 
      NSLog(@"Orientation - Right"); 
      break; 
     case UIInterfaceOrientationPortraitUpsideDown: 
      NSLog(@"Orientation - UpsideDown"); 
      break; 
     default: 
      break; 
    } 
    return YES; 
} 

Lorsque je tourne mon appareil, cette méthode est appelée pour LandscapeRight, LandscapeLeft et UpsideDown, mais pas pour l'orientation Portrait. Au lancement, la vue est en mode portrait et cette méthode est appelée avec UIInterfaceOrientationPortrait. Mais quand je fais tourner l'appareil, cette méthode n'est pas appelée uniquement pour cette orientation.

Répondre

0

shouldAutorotateToInterfaceOrientation est normalement appelée une seule fois pour indiquer à l'appelant quelles orientations l'application prendra en charge (une valeur OU ou YES pour tous). Il se peut que vous cherchiez willRotateToInterfaceOrientation:duration: pour vérifier l'orientation et/ou effectuer quelques réarrangements avant d'afficher la nouvelle orientation.

+0

Je veux faire pivoter le UIImageView central dans ma vue principale sans faire tourner toute l'interface. – Steven

Questions connexes