简体   繁体   English

图像方向在启动时变形为错误的方向(iOS)

[英]Image orientation distorts to the wrong orientation on startup (iOS)

I have an app, haven't modified it since 6 months ago, anyway I decided to open it up in the simulator. 我有一个应用程序,自6个月前以来就没有对其进行过修改,无论如何,我决定在模拟器中将其打开。 But the first viewcontroller which shows after the splash screen is scrunched up and is showing through the wrong orientation. 但是,在启动屏幕被收缩并通过错误的方向显示后显示的第一个viewcontroller。 It's showing in portrait when it should be showing in landscape. 它应该以横向显示时是纵向显示。

This is the code for it: 这是它的代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

However, 然而,

When I tap to go to another view, then go back to the main viewcontroller, the problem fixes itself and the orientation is correct. 当我点击以转到另一个视图,然后返回到主视图控制器时,问题已修复,并且方向正确。

正确显示

So it only happens on the initial launch after the splash screen is shown. 因此,它仅在显示初始屏幕后才发生。

Please join the links together to view the screenshots as i cannot post images as i haven't got 10 reps yet. 由于我还没有10次代表,因此我无法发布图片,请将这些链接一起查看截图。

在此处输入图片说明 This will make sure the app to open in landscape mode . 这将确保该应用程序以横向模式打开。

In the AppDelegate you may be using this 在AppDelegate中,您可能正在使用此

[self.window addSubView:viewControllerObj]

The problem was with the above line. 问题出在上面的那一行。 Orientation will work properly with the above line in iOS 5 but in iOS 6, for orientation to work properly, change the above line with 定向将在iOS 5中与上述行一起正常工作,但在iOS 6中,为使定向正常工作,请使用

[self.window setRootViewController:viewControllerObj]

Then the app rotates when orientation changes 然后,当方向改变时,应用程序旋转

Open your plist file ->addRow-> add "Initial interface orientation" and give value Landscape (left home button). 打开您的plist文件-> addRow->添加“初始界面方向”,并赋予值Landscape(左主页按钮)。

Hope this will help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM