ios - ios6 中的自动旋转未按预期工作

标签 ios iphone ios6 autorotate

我的应用程序中有两个 View ; “计算器”和“磁带”。我可以单击计算器内的按钮来访问磁带,反之亦然。我按照下面的代码设置了旋转,大多数情况下都工作正常。

但是,如果我将计算器 View 或磁带 View 旋转为横向,然后如果我尝试访问其他 View ,界面就会变得一团糟,就像它无法识别设备已经旋转一样。有什么建议吗?

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [self doLayoutForOrientation:toInterfaceOrientation]; 
}


- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation { 
if (UIInterfaceOrientationIsPortrait(orientation)) 
{
//set the frames here
}
else 
{
//set the frames here
} 
}

最佳答案

在每个 View 都会出现的 View 中写入这些代码。

 UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//adjust the view for landscape
}
else if(orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
//adjust the view for portrait.
}

关于ios - ios6 中的自动旋转未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21992563/

相关文章:

iphone - IOS UiView动画在ios 5和ios 6设备上产生不同的效果

iphone - 如何设置一个 View 与另一个 View 的时间间隔

ios - NSDateFormatter 根据 iOS 版本返回不同的结果

iphone - iOS 5 UIButton 标题显示省略号

ios - 使用 'MKMapView' 显示多个位置

iphone - 将按钮组合在一起以便于操作

ios - 使用未声明的类型 'Object'

ios - iOS 中的 Google Drive REST

iOS - 保存到库/缓存/会导致错误吗?

ios - 删除通用存折中缩略图周围的白色边框?