ios 无法在 iPhone 6.0 Simulator Retina 4 英寸上全屏启动我的应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12508861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 20:15:56  来源:igfitidea点击:

Unable to start my application in full screen on iPhone 6.0 Simulator Retina 4 Inch

iphoneiosios-simulatorios6

提问by uerceg

I have added [email protected]to my project and set it in project settings, I have also set autoresizing optionsfor my view and elements on that view which is initially loading on my application which is landscape-only, but after running my application in iOS 6.0 Simulator Retina 4 inch I see my application moved all the way left, leaving black pixel area on the right.

我已将[email protected]添加到我的项目并在项目设置中进行设置,我还为我的视图和该视图上的元素设置了自动调整选项,该视图最初加载到我的仅横向应用程序上,但在运行后我在 iOS 6.0 Simulator Retina 4 英寸中的应用程序我看到我的应用程序一直向左移动,在右侧留下黑色像素区域。

Any idea what should I do beside these things in order to see my application runs in "full screen" on iOS 6.0 Simulator Retina 4 inch?

知道除了这些事情我还应该做什么才能看到我的应用程序在 iOS 6.0 Simulator Retina 4 英寸上以“全屏”运行?



[edit #1: AppDelegate]

[编辑#1:AppDelegate]

I also edited my AppDelegate.m like this:

我还像这样编辑了我的 AppDelegate.m:

viewControllerMain = [[ViewControllerMain alloc] init];
//[window addSubview:viewControllerMain.view];
window.rootViewController = viewControllerMain;


[edit #2: Editing frame]

[编辑#2:编辑框]

I managed to achieve full screen mode, but it's not working as it should. I do this in my views:

我设法实现了全屏模式,但它不能正常工作。我在我的观点中这样做:

CGRect frame = CGRectMake([UIScreen mainScreen].bounds.origin.x, [UIScreen mainScreen].bounds.origin.y, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
self.frame = frame;

This only brings my view to full screen, but black area on the right I mentioned on the beginning is deadand no user interaction is possiblein that area (I have UIButton there which doesn't react on touch). So basically, what I did only made my view appear in full resolution, but functionality of elements on view is limited to area where my app originally showed when I first started it on Retina 4 inch simulator.

这只会使我的视图全屏显示,但是我在开头提到的右侧的黑色区域已死,并且该区域无法进行用户交互(我在那里有 UIButton,它不会对触摸做出反应)。所以基本上,我所做的只是让我的视图以全分辨率显示,但视图中元素的功能仅限于我的应用程序最初在 Retina 4 英寸模拟器上启动时最初显示的区域。



[edit #3: Changing size of UIView's in XIB files]

[编辑 #3:在 XIB 文件中更改 UIView 的大小]

I even tried to change actual size of UIView's in my XIB files resizing them all to Regina 4 Full Screen, but still - same thing.

我什至试图在我的 XIB 文件中更改 UIView 的实际大小,将它们全部调整为 Regina 4 全屏,但仍然 - 同样的事情。



[edit #4: Changing size of window object]

[编辑#4:改变窗口对象的大小]

I have tried to change size of window object in AppDelegate.m but again no luck. Here's how AppDelegate.m look like.

我试图在 AppDelegate.m 中更改窗口对象的大小,但还是没有运气。这是 AppDelegate.m 的样子。

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;

mainViewController = [[MainViewController alloc] init];
window.rootViewController = mainViewController;

// Override point for customization after application launch
[window setFrame:[UIScreen mainScreen].bounds];
[window makeKeyAndVisible];


[edit #5: "Solution"]

[编辑#5:“解决方案”]

So far I did following: In IB I made new UIViews with iPhone 5 resolution size, assigned same owner classes which are handling their equivalent UIViews made for pre iPhone 5 resolution and in code where do I need to load some of these UIViews I check [UIScreen mainScreen].borders to determine which device is currently running my application. In this way, I managed to get things work.

到目前为止,我做了以下工作:在 IB 中,我制作了具有 iPhone 5 分辨率大小的新 UIViews,分配了相同的所有者类,这些类正在处理为 iPhone 5 之前的分辨率制作的等效 UIViews 以及在代码中我需要在哪里加载这些 UIViews 中的一些我检查 [ UIScreen mainScreen].borders 以确定当前正在运行我的应用程序的设备。通过这种方式,我设法使事情顺利进行。

But still, main question remained - why didn't all my UIViews automatically stretched to new resolution after I did all those things I mentioned?

但是,主要问题仍然存在 - 为什么在我做了我提到的所有这些事情之后,我的所有 UIViews 没有自动拉伸到新的分辨率?

Anyhow, bounty remains active for 5 or 6 days. If someone manages to solve this issue, I'd be very grateful. If not, I'll give bounty to @onegray, since that was the thing I didn't took care of at first place, and in my current implementation it is really important.

无论如何,赏金会持续 5 或 6 天。如果有人设法解决这个问题,我将不胜感激。如果没有,我会给@onegray提供奖励,因为这是我一开始没有注意的事情,而在我目前的实施中,这非常重要。

Best regards.

此致。



[edit #6: MainWindow.xib Full Screen at Launch option]

[编辑 #6:启动选项时的 MainWindow.xib 全屏]

As @user1702985suggested, I turned this option ONas it was deselected. But no luck.

正如@ user1702985建议的那样,我在取消选择此选项时将其打开。但没有运气

When I start my application I show one View for 2 seconds with one UIImageView on it. If I set Autosize properties right, this UIView is shown in fullscreen on iPhone 5 simulator. BUT. After that I have second UIView which contains vertical UIScrollView, UIViews as header and footer and one UIButton, and I also set all autosize options for these elements, but this UIView is shown in iPhone 4-- resolution. It really acts strange and I still don't know what can it be.

当我启动我的应用程序时,我会在 2 秒内显示一个视图,上面有一个 UIImageView。如果我正确设置 Autosize 属性,则此 UIView 将在 iPhone 5 模拟器上全屏显示。但。之后,我有第二个 UIView,其中包含垂直 UIScrollView、UIViews 作为页眉和页脚以及一个 UIButton,我还为这些元素设置了所有自动调整选项,但此 UIView 显示在 iPhone 4 分辨率中。它真的很奇怪,我仍然不知道它是什么。



[edit #7: Auto-resizing options which are set]

[编辑 #7:设置的自动调整大小选项]

This auto-resizing option is set for all my UIViews and it's elements.

这个自动调整大小选项是为我所有的 UIViews 和它的元素设置的。

enter image description here

在此处输入图片说明



[edit #8: Explanation of Full Screen at Launch option]

[编辑 #8:启动选项时全屏的说明]

MainWindow.xib properties.

MainWindow.xib 属性。

enter image description here

在此处输入图片说明

采纳答案by onegray

Make sure that key window has proper size. Workaround is to set proper frame: [window setFrame:[[UIScreen mainScreen] bounds]].

确保键窗口大小合适。解决方法是设置适当的框架:[window setFrame:[[UIScreen mainScreen] bounds]].

Update:
It is difficult to guess where is the problem without having the source code. I've created simple app stub to test interface orientation for iPhone4/iPhone5. I just created new "Single View Application", added some subviews to the root view, and added "Defaults" images. I did it in Xcode 4.3.2 without any extra features of Xcode 4.5.And app automatically stretches its screen to proper size (for both portrait/landscapeorientations).

更新:
如果没有源代码,很难猜测问题出在哪里。我创建了简单的应用存根来测试 iPhone4/iPhone5 的界面方向。我刚刚创建了新的“单一视图应用程序”,向根视图添加了一些子视图,并添加了“默认”图像。我在 Xcode 4.3.2 中做到了,没有任何额外的功能,Xcode 4.5.并且应用程序会自动将其屏幕拉伸到适当的大小(对于两个portrait/landscape方向)。

回答by Ashvin Ajadiya

I hope this will help you but not sure that you will got touch effect in full screen, So you have to check for full touch for your application.

我希望这会对您有所帮助,但不确定您是否会在全屏下获得触摸效果,因此您必须检查您的应用程序是否为全触摸。

Step 1: Click On Project from Navigation shown in image and click on missing file

步骤 1:从图像中显示的导航中单击项目,然后单击丢失的文件

Step 2: In second image click on Add

第 2 步:在第二张图片中点击添加

Now run project your project will run in Full iPhone 5 screen or simulator.!

现在运行项目你的项目将在完整的 iPhone 5 屏幕或模拟器中运行。!

enter image description here

在此处输入图片说明

回答by user1702985

I had the same issue of part of the screen not responding to user interaction. Selecting the "Full Screen at launch" option on the MainWindow.xib fixed it for me.

我遇到了相同的问题,即屏幕的一部分没有响应用户交互。在 MainWindow.xib 上选择“启动时全屏”选项为我修复了它。

回答by John Ballinger

No matter what I did, I could not get my app fullscreen.

无论我做什么,我都无法全屏显示我的应用程序。

But after I added a file "[email protected] to my app. Now all the xib's run full screen. You can quickly test this by making a new app in XCode and copying the the black png that was created.

但是在我将文件“[email protected] 添加到我的应用程序之后。现在所有的 xib 都全屏运行。您可以通过在 XCode 中创建一个新应用程序并复制创建的黑色 png 来快速测试这一点。

回答by Vlad

If you use XCode 6.1 try this solution (for projects without full image set):

如果您使用 XCode 6.1,请尝试此解决方案(对于没有完整图像集的项目):

  1. Project -> Target -> General -> App Icons and Launch Images -> Launch Screen file
  2. Choose xib for first screen.
  1. 项目 -> 目标 -> 常规 -> 应用程序图标和启动图像 -> 启动屏幕文件
  2. 选择 xib 作为第一个屏幕。

回答by user1834011

did you try this?

你试过这个吗?

iOS Simulator > Hardware > Device > iPhone(Retina 4-inch)

iOS 模拟器 > 硬件 > 设备 > iPhone(Retina 4-inch)

i just run into the same problem and this is how i solved.

我只是遇到了同样的问题,这就是我解决的方法。

回答by dklt

Delete App on simulator by LongPress-ing and re-run.

通过 LongPress-ing 删除模拟器上的应用程序并重新运行。

This works for me, after 4 inch retina adjustments. Everything was auto-resized the way I stitch-up in IB.

在 4 英寸视网膜调整后,这对我有用。一切都是按照我在 IB 中拼接的方式自动调整大小的。

回答by Ben Clayton

How are you adding the main viewController to the window? Just adding the view as a subview isn't supported any more in iOS6.

你如何将主视图控制器添加到窗口?iOS6 不再支持将视图添加为子视图。

Here's an except from an article on my blog about making apps work on the iPhone 5 screen size.

这是我博客上关于使应用程序在 iPhone 5 屏幕尺寸上运行的文章中的一个例外。

Use window.rootViewController to add your initial view

使用 window.rootViewController 添加初始视图

First up, if you're building your initial views in code make sure you add your initial view to the window with window.rootViewController rather than the old way of simply adding the view as a subview. If you don't do this, autorotating will not work at all for your app under iOS 6.

首先,如果您在代码中构建初始视图,请确保使用 window.rootViewController 将初始视图添加到窗口,而不是简单地将视图添加为子视图的旧方法。如果您不这样做,在 iOS 6 下,自动旋转对于您的应用程序根本不起作用。

Here's an example:

下面是一个例子:

navigationController = [[UINavigationController alloc] initWithRootViewController: myRootVC];
//[window addSubview:[navigationController view]]; Don't do this!
window.rootViewController = navigationController; // Do this instead!

More at http://pervasivecode.blogspot.co.uk/2012/09/making-apps-work-on-iphone-5-screen-size.html

更多信息见http://pervasivecode.blogspot.co.uk/2012/09/making-apps-work-on-iphone-5-screen-size.html

回答by Chathurka

Please add launch screen for application.

请为应用程序添加启动屏幕。

回答by diadyne

We ran into a similar issue on an app that was created back in the iOS 6 days when testing on iOS 8.

我们在 iOS 6 天后在 iOS 8 上测试时创建的应用程序上遇到了类似的问题。

The fix for us was setting the "Hidden" flag on MainWindow.xib.

我们的修复是在 MainWindow.xib 上设置“隐藏”标志。

This is how we found out about the fix here.

这就是我们在此处发现修复的方式。