インターフェイスの向きに応じたフレーム
-
08-10-2019 - |
質問
uialertviewにuitextfieldがあります。オリエンテーションが変更されたら、UIALERTVIEWのボタンと重複するため、UITEXTFIELDのフレームを更新したいと思います。これらはフレームです:
portrait: CGRectMake(12.0, 45.0, 260.0, 26.0)
landscape: CGRectMake(12.0, 30.0, 260.0, 26.0)
デバイスの向きが変更されたかどうかを確認するにはどうすればよいですか それなし 加速度計を直接使用しますか?
入るべきです -[UIViewController shouldAutorotateToInterfaceOrientation:]
?
解決
これを試して
if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation]==UIInterfaceOrientationLandscapeRight)
{
//Landscape Frame
}
if([[UIDevice currentDevice] orientation]==UIInterfaceOrientationPortrait)
{
//Portrait Frame
}
所属していません StackOverflow