0

J'ai un UITextField dans un UIAlertView. Lorsque l'orientation change, je veux mettre à jour le cadre de l'UITextField car il chevaucherait autrement les boutons de UIAlertView. Ce sont les cadres:Cadre en fonction de l'orientation de l'interface

portrait: CGRectMake(12.0, 45.0, 260.0, 26.0) 
landscape: CGRectMake(12.0, 30.0, 260.0, 26.0) 

Comment puis-je vérifier si l'orientation de l'appareil a changé sans en utilisant l'accéléromètre directement?

Devrait-il être en -[UIViewController shouldAutorotateToInterfaceOrientation:]?

Répondre

2

Essayez cette

if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight) 
{ 
    //Landscape Frame 
} 
if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait) 
{ 
    //Portrait Frame 
} 
+0

Oui, mais comment mon application savoir quand il est en fait une rotation? –

+0

Chaque fois que vous faites pivoter votre appareil, ce délégué sera appelé - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { – iPrabu