IOS XIB 故事板启动屏幕文件显示内部图像的方向错误
IOS XIB storyboard Launch Screen file displays wrong orientation of an image inside
我在 ejecta kitchen 的支持下使用基于 js 的应用程序。我的问题是我在 MainWindow 上设置的图像显示错误的方向,或者换句话说,它显示固定的方向。我的应用程序要求所有内容都以横向模式显示,但每当我更改 IPAD.
的方向时,XIB 文件就会颠倒显示内容
我在互联网上搜索了很多,但我找不到任何可能的解决方案 yet.This 是唯一有这个问题的文件,除此之外我的 index.html 文件工作正常,它是建立在 construct2 上的.
这是显示我的 window 和图像
层次结构的图像
根据您的问题,您可以在 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);
}
}
按照上面的代码,您可以旋转背景图片。
我在 ejecta kitchen 的支持下使用基于 js 的应用程序。我的问题是我在 MainWindow 上设置的图像显示错误的方向,或者换句话说,它显示固定的方向。我的应用程序要求所有内容都以横向模式显示,但每当我更改 IPAD.
的方向时,XIB 文件就会颠倒显示内容我在互联网上搜索了很多,但我找不到任何可能的解决方案 yet.This 是唯一有这个问题的文件,除此之外我的 index.html 文件工作正常,它是建立在 construct2 上的.
这是显示我的 window 和图像
层次结构的图像根据您的问题,您可以在 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);
}
}
按照上面的代码,您可以旋转背景图片。