因此,我们正在使用第三方HUD模块。它有点不稳定,为了让它弹出所有的内容,我扩展了它,以便使用代码来显示自己。
[[UIApplication sharedApplication keyWindow] addSubview:self.view];
但是,在横向模式或倒置模式下,弹出窗口会出现旋转(或者更准确地说,不旋转,始终与设备对齐,而不是界面)。我在iOS是个新手,所以我不知道为什么,但我添加了一些代码来弥补
bool go = false;
float angle = 0.0;
if (mode == OLM_LandscapeLeft) // I calculate this further above, it works
{
go = true;
angle = 90;
}
[[[UIApplication sharedApplication] keyWindow] addSubview:self.view];
if (go)
{
float rads = (angle) / 180 * M_PI;
CGAffineTransform transform = CGAffineTransformRotate(CGAffineTransformIdentity, rads);
self.view.transform = transform;
}无论我是在keyWindow.addSubview之前还是之后应用转换,这似乎都没有任何效果。
有没有一种正确的,或者至少是有效的方法来做到这一点?如果有人能教我为什么这类addSubView似乎忽略了接口方向,那就太好了。
发布于 2014-09-25 16:04:37
也许您正在使用UIDeviceOrientation,但应该使用UIInterfaceOrientation。
您可以通过以下方式接收此信息:
[[UIApplication sharedApplication] statusBarOrientation]马基罗斯人:
UIInterfaceOrientationIsLandscape
UIInterfaceOrientationIsPortrait这样你就不用用:
OLM_LandscapeLeft // might have a computation bughttps://stackoverflow.com/questions/26042353
复制相似问题