我正在喷射引擎厨房的支持下使用基于js的应用。我的问题是我在MainWindow上设置的图像显示了错误的方向,或者换句话说,它显示了固定的方向。我的应用程序要求所有内容都必须以横向模式显示,但是每当我更改IPAD的方向时,XIB文件都将其上下颠倒显示。
我已经在Internet上进行了大量搜索,但是我还没有找到任何可能的解决方案。这是唯一有此问题的文件,除此之外,我的index.html文件可以在Construct2上正常运行。
这里是显示窗口和图像层次结构的图像
根据您的问题,您可以按照以下AppDelegate
方法编写代码。
- (void) application:(UIApplication *)application willChangeStatusBarOrientation:(UIInterfaceOrientation)newStatusBarOrientation
duration:(NSTimeInterval)duration
{
if (newStatusBarOrientation == UIInterfaceOrientationPortrait)
yourImage.transform = CGAffineTransformIdentity;
else if (newStatusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
yourImage.transform = CGAffineTransformMakeRotation(-M_PI);
else if (UIInterfaceOrientationIsLandscape(newStatusBarOrientation))
{
float rotate = ((newStatusBarOrientation == UIInterfaceOrientationLandscapeLeft) ? -1:1) * (M_PI / 2.0);
yourImage.transform = CGAffineTransformMakeRotation(rotate);
yourImage.transform = CGAffineTransformTranslate(yourImage.transform, 0, -yourImage.frame.origin.y);
}
}
根据上述代码,您可以旋转背景图像。