2010-07-06 3 views

Répondre

0

Même moi j'ai fait face au problème, Si vous voulez juste savoir si l'orientation de l'appareil a changé ou pas utiliser la notification au lieu de shouldAutorotateToInterfaceOrientation.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; 
-(void)orientationChanged:(NSNotification *)dict 
{ 
    UIInterfaceOrientation interfaceOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation; 
    //Your code 
} 

Pour le problème d'origine, Par défaut shouldAutorotateToInterfaceOrientation retour OUI pour UIDeviceOrientationPortrait Si vous êtes retourné NO dans méthode shouldAutorotateToInterfaceOrientation, dispositif pensera que son en le mode UIDeviceOrientationPortrait ne donc la méthode shouldAutorotateToInterfaceOrientation n'est pas appelé UIDeviceOrientationPortrait.

(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
     //your code 
     return NO; 
} 
+0

Renvoyez-vous NO dans la méthode shouldAutorotateToInterfaceOrientation toujours. –

0

Avez-vous essayé avec Device and Simulator? Avez-vous vérifié l'orientation prise en charge dans votre app_name-Info.plist?

+0

J'essaie dans les deux. Même résultat et dans .plist je ne change rien ou ne limite rien? –

+0

Cela vous paraît-il étrange que vous n'ayez pas la touche "Oriented interface orientation" dans le fichier PList? – Greensource

+0

damm sûr .. nuthing liée à l'orientation. –

Questions connexes