2009-06-22 4 views

Répondre

8

Votre contrôleur de vue sera envoyé:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

Mettre en oeuvre pour faire quelque chose lorsque le téléphone est en rotation

Après la rotation se fait, vous obtenez:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

ici il est dans les documents (voir Gestion des rotations de vue)

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html

1

Lorsque vous faites pivoter le périphérique, votre contrôleur de vue reçoit un message didRotateFromInterfaceOrientation: , avec l'ancienne orientation. Vous pouvez vérifier la propriété interfaceOrientation pour voir la rotation en cours, et faire quelque chose en conséquence.

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
1

Vous devez capturer les événements envoyés avant la rotation de ViewController. A savoir:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

et post rotation

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
0

Les noms de méthode sont corrects ... mais ils ne sont jamais appelés. Qu'est-ce qui causerait cela?

1

Vous devez d'abord implémenter la méthode d'instance "shouldAutorotateToInterfaceOrientation" et renvoyer YES. puis la méthode deux sera appelée.

Questions connexes