gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:07:29 26 4
gpt4 key购买 nike

我的应用中有两个 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
}
}

最佳答案

将这些代码写在viewwill appear of each 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com