2010-05-03 6 views

Répondre

7

Définir la « orientation de l'interface initiale » d'entrée app.plist à « Paysage » (bouton maison à gauche ou à droite) et ajouter (ou plus probablement, décommenter et modifier) ​​la méthode de contrôleur de vue suivant:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); 
} 
+1

vouliez-vous dire: return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight; – progrmr

+0

Non, je l'ai prévu pour forcer une orientation paysage unique (c'est comme ça que je le concevrais), mais votre point est tout à fait valide. Je suppose que cela se résume à l'intention sous-jacente du PO. –

+1

Comme d'autres l'ont mentionné, 'UIInterfaceOrientationLandscape' n'est pas une énumération valide; vous avez besoin de 'UIInterfaceOrientationLandscapeLeft' ou' UIInterfaceOrientationLandscapeRight' si vous en vouliez seulement un (pour des raisons de compréhension) ou 'return UIInterfaceOrientationIsLandscape (interfaceOrientation);' pour prendre en charge l'orientation paysage. –

6

réponse de Marcelo est pas correct, car UIInterfaceOrientationLandscape n'est pas un identifiant valide et apporte ainsi une accumulation sûr.

La réponse de progrmr est correcte:

return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight; 

(Toutes mes excuses pour ne pas commenter la première réponse, mais je n'ai pas eu assez de points de réputation quand j'ai écrit ça ...)

Questions connexes