1
我的应用程序中有一个UIImageView内的UIImage。在旋转后自动居中UIImageView
在纵向模式下,图像居中,但当我切换到横向模式时,它仍然位于左侧。
所以我在我的.m文件中添加了以下方法,但问题是我有一个TabBar应用程序,所以当我在另一个选项卡上旋转设备并返回包含图像的选项卡时,自动旋转。
有一种方法可以在任何选项卡上旋转设备时自动旋转应用程序的所有元素?
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if((self.interfaceOrientation == UIDeviceOrientationLandscapeLeft) || (self.interfaceOrientation == UIDeviceOrientationLandscapeRight)){
background.image = [UIImage imageNamed:@"back2-landscape.png"];
} else if((self.interfaceOrientation == UIDeviceOrientationPortrait) || (self.interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)){
background.image = [UIImage imageNamed:@"back2-portrait.png"];
}
}
谢谢:-)
我使用第一种方法做了它,并且它完美地工作。非常感谢你 :-) – bnabilos 2010-10-31 01:36:29