【发布时间】:2014-05-09 15:47:47
【问题描述】:
我对 iOS 开发还很陌生,只是继承了一堆 iOS 代码。
我正在尝试开始使用自动布局和约束,以便更轻松地支持不同的屏幕尺寸和 iOS 版本。我发现一旦我将故事板更改为使用自动布局,当我将 iPad 旋转到横向视图时,背景图像就不再改变。我不确定这是否是阻止此更改的自动布局,或者是否有其他方法可以切换背景图像。我会很感激你的帮助。
这是我的旋转方法。
- (void)didRotate
{
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
if ([[UIDevice currentDevice] userInterfaceIdiom] != UIUserInterfaceIdiomPhone)
{
if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
{
[backgrndView setBackgroundImage:[UIImage imageNamed:@"menu_ipad2.png"] forState:UIControlStateNormal] ;
}
else if (orientation == UIDeviceOrientationPortraitUpsideDown|| orientation == UIDeviceOrientationPortrait)
{
[backgrndView setBackgroundImage:[UIImage imageNamed:@"menu_ipad.png"] forState:UIControlStateNormal] ;
}
[backgrndView sizeToFit];
}
}
【问题讨论】:
标签: ios ipad autolayout