2009-06-10 9 views

Répondre

4

Vous implémentent le support d'orientation par:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
// Just delete the lines for the orientations you don't want to support 
    if((toInterfaceOrientation == UIInterfaceOrientationPortrait) || 
    (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)) || 
    (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)) || 
    (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) { 
    return YES; 
    } 
return NO; 
} 

ensuite de charger une nouvelle ViewController lors de la rotation:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
    if((fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || 
    (fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) 
    {  
    // Load the view controller you want to display in portrait mode... 
    } 
} 

Vous pouvez même mettre en place une animation pour manipuler la propriété alpha de la nouvelle vue, si vous vouliez faire une transition en douceur, comme vous le voyez dans l'application iPod quand elle passe à Cover Mode de débit

DISCLAIMER La méthode préférée de prise en charge des changements de rotation de l'interface dans 3.0. La méthode ci-dessus fonctionnera toujours, mais il existe un moyen d'obtenir une animation plus fluide. Mais nous ne sommes pas censés en parler ici pour un. plus. la semaine.

ANOTHERvDISCLAIMER La méthode préférée de prise en charge de la rotation de l'interface change à nouveau en 6.0. La méthode ci-dessus fonctionnera toujours, mais il existe un moyen d'obtenir une animation plus fluide.

0

Pour la rotation de l'appareil, vous devez mettre en œuvre cette méthode dans votre viewController:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

Questions connexes