Cadre selon l'orientation de l'interface
-
08-10-2019 - |
Question
J'ai un UITextField dans un UIAlertView. Lorsque les changements d'orientation, je veux mettre à jour le cadre du UITextField parce qu'elle serait autrement chevaucher les boutons de la UIAlertView. Ce sont les cadres:
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?
Faut-il en -[UIViewController shouldAutorotateToInterfaceOrientation:]
?
La solution
Essayer cette
if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight)
{
//Landscape Frame
}
if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait)
{
//Portrait Frame
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow