我在uialertview中有一个uitextfield。当方向更改时,我想更新UITEXTFIELD的框架,因为否则它将与UialerTview的按钮重叠。这些是框架:

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
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top