我的应用程序在纵向和横向之间来回切换。我已将我的所有内容(标签、uiimageviews、uilabels)排成一行,以便为两个方向重新定位。但是,只有在设备实际旋转时才会发生变化。当我在它旋转后在选项卡之间循环时,它只会显示自动调整大小,而不是当用户旋转它时我设置它的方式。
当点击不同的选项卡时,如何检测设备的方向并显示视图以反映方向?
好的,我将其设置为 viewWillAppear。它没有检测方向并显示我设置的内容是否有原因?
-(void)viewWillAppear:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration{
UIInterfaceOrientation toOrientation = self.interfaceOrientation;
[UIView beginAnimations:@"move buttons" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if(toOrientation == UIInterfaceOrientationPortrait
|| toOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
aboutContent.frame = CGRectMake(20, 100, 280, 107);
myLogo.frame = CGRectMake(-5, 20, 330, 65);
bulletOne.frame = CGRectMake(40, 220, 240, 45);
bulletTwo.frame = CGRectMake(40, 270, 240, 45);
}
else
{
aboutContent.frame = CGRectMake(40, 80, 400, 70);
myLogo.frame = CGRectMake(230, 30, 20, 20);
bulletOne.frame = CGRectMake(90, 140, 330, 65);
bulletTwo.frame = CGRectMake(90, 170, 330, 65);
}
[UIView commitAnimations];
}