Soutenir uniquement l'orientation portrait
-
27-09-2019 - |
Question
Je dois soutenir que l'orientation portrait dans mon application. Comment puis-je le faire? Je l'ai essayé d'ajouter
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
et
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationPortrait;
}
Mais il does't aide -. La vue tourne de toute façon
Merci à l'avance!
La solution
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
should renvoie un BOOL qui est NO
in votre cas.
Autres conseils
Cela devrait être:
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return interfaceOrientation == UIInterfaceOrientationPortrait
|| interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;
}
Dans XCode 5 (pas sûr versions antérieures), si vous voulez en mode portrait de soutien seulement à travers l'application entière, allez à projet Paramètres-> Général-> Infos déploiement et décocher Upside Down, Orientation Gauche et Droite Orientation.
Ceci est probablement la meilleure façon de le faire maintenant.
Pour iOS 6, il semble que vous devez ajouter / remplacer cette méthode aussi,
-(BOOL)shouldAutorotate {
return NO;
}