Est-il possible de désactiver l'animation pour l'autorotation? Je veux qu'il tourne, mais je ne veux pas que l'animation se produise (comme un interrupteur instantané).iphone autorotation animation
Répondre
Il suffit d'ajouter le code suivant pour remplacer l'animation de rotation standard:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
- (void)didRotate:(NSNotification *)notification {
orientation = [[UIDevice currentDevice] orientation];
if(orientation == UIDeviceOrientationUnknown || orientation == UIDeviceOrientationFaceDown || orientation == UIDeviceOrientationFaceUp){
orientation = UIDeviceOrientationPortrait;
}
[[UIApplication sharedApplication] setStatusBarOrientation:orientation animated:NO];
[self positionScreenElements];
}
Cette réponse a bien fonctionné, mais j'ai eu quelques problèmes lors de la mise au point d'un champ de texte. Si l'iPad était à plat sur le bureau, le clavier apparaissait à moitié hors écran - très étrange. Le problème était que l'orientation du périphérique pouvait également être inconnue, face vers le haut ou face vers le bas, sans que cela corresponde à l'orientation de la barre d'état. La vérification de ces états a rendu cela parfait. Un grand merci Nils pour m'avoir sauvé w/cette solution :) –
+1 adam pour votre contribution:] –
Qu'est ce que "orientation"? – Morkrom
Si vous avez vraiment besoin, il suffit d'utiliser setAnimationsEnabled
de UIView
:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[UIView setAnimationsEnabled:NO]; // disable animations temporarily
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[UIView setAnimationsEnabled:YES]; // rotation finished, re-enable them
}
Il fait l'affaire pour moi. Bien sûr, il n'est pas recommandé de le faire à moins d'avoir une très bonne raison de le faire.
c'est super !, merci! –
@Nils Munch malheureusement cela ne fonctionne pas correctement, le setStatusBarOrientation attend UIInterfaceOrientation
pas UIDeviceOrientation
et le casting est une mauvaise pratique. Corrigez-moi si je me trompe
- 1. personnalisée autorotation iPhone SDK
- 2. iphone autorotation fond noir
- 3. Animation iPhone
- 4. UITabBarController + autorotation
- 5. autorotation UINavigationController
- 6. Jouer Animation avec temps specf [Animation iPhone]
- 7. iPhone Image Zoom Animation
- 8. iPhone: animation vectorielle
- 9. iPhone UIImageView animation malheurs
- 10. Iphone animation 3D
- 11. Animation UIImageView iPhone
- 12. iPhone UILabel animation
- 13. iphone imageview séquence animation
- 14. Animation d'écriture manuscrite Iphone
- 15. autorotation pour une vue
- 16. TTThumbView/TTPhotoView pas autorotation
- 17. Comment désactiver une autorotation?
- 18. Autorotation et redimensionnement
- 19. iOS: AutoRotation entre NIBs
- 20. Contrôleur UINavigation et Autorotation
- 21. Animation iPhone avec image extensible
- 22. iPhone page curl transition animation
- 23. Core Animation performance sur iphone
- 24. Animation iPhone: comment l'anti-alias?
- 25. Autorotation avec un contrôleur UINavigation
- 26. iPhone Dev: animation de séquences PNG
- 27. animation bloque une boucle infinie - iphone
- 28. Iphone animation - Calcul pour tracer cartésien Coordonnées
- 29. Big animation iPhone avec CCSpriteFrameCache - plist
- 30. iPhone SDK: UIImageView - Animation de réduction
L'animation est la beauté de celui-ci! –
Eh bien je l'ai mis en place pour que l'image BG change en une version horiz, ou vert de l'image en fonction de l'orientation et l'animation de rotation provoquait un pépin quand l'image a changé mais je l'ai joué d'accord quand même. – Brodie