简体   繁体   English

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

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

I have added Default-568h@2x.png to my project and set it in project settings, I have also set autoresizing options for 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. 我已将Default-568h@2x.png添加到我的项目中并在项目设置中设置它,我还为我的视图和该视图上的元素设置了自动调整选项 ,该视图最初是在我的应用程序上加载的,仅限于横向,但是在运行之后我的应用程序在iOS 6.0模拟器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模拟器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 dead and no user interaction is possible in that area (I have UIButton there which doesn't react on touch). 这只会让我的视图全屏显示,但我在开头提到的右边的黑色区域已经死了 ,在那个区域没有用户交互 (我有UIButton那里没有反应)。 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. 基本上,我所做的只是使我的视图以全分辨率显示,但视图中元素的功能仅限于我第一次在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. 我试图在AppDelegate.m中更改窗口对象的大小,但再次没有运气。 Here's how AppDelegate.m look like. 这是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. 到目前为止,我做了以下操作:在IB中我制作了具有iPhone 5分辨率大小的新UIViews,分配了相同的所有者类,它们正在处理为iPhone 5分辨率而制作的等效UIViews以及在代码中我需要加载一些这些UIViews我检查[ UIScreen mainScreen] .borders确定当前正在运行我的应用程序的设备。 In this way, I managed to get things work. 通过这种方式,我成功地完成了工作。

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. 无论如何,赏金仍然活跃5或6天。 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. 如果没有,我会给@ onegray奖励 ,因为那是我在第一时间没有照顾的事情,而且在我目前的实施中它非常重要。

Best regards. 最好的祝福。


[edit #6: MainWindow.xib Full Screen at Launch option] [编辑#6:启动时的MainWindow.xib全屏选项]

As @ user1702985 suggested, I turned this option ON as it was deselected. 正如@ user1702985的建议,我打开这个选项 ,因为它是取消。 But no luck . 没有运气

When I start my application I show one View for 2 seconds with one UIImageView on it. 当我启动我的应用程序时,我用一个UIImageView显示一个View 2秒。 If I set Autosize properties right, this UIView is shown in fullscreen on iPhone 5 simulator. 如果我正确设置自动调整大小属性,则此UIView将在iPhone 5模拟器上全屏显示。 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. 之后,我有第二个UIView,其中包含垂直UIScrollView,UIViews作为页眉和页脚以及一个UIButton,我还为这些元素设置了所有自动调整大小选项,但是这个UIView显示在iPhone 4--分辨率中。 It really acts strange and I still don't know what can it be. 它真的很奇怪,我仍然不知道它能是什么。


[edit #7: Auto-resizing options which are set] [编辑#7:自动调整大小的选项]

This auto-resizing option is set for all my UIViews and it's elements. 这个自动调整大小选项是为我的所有UIViews及其元素设置的。

在此输入图像描述


[edit #8: Explanation of Full Screen at Launch option] [编辑#8:启动时全屏说明]

MainWindow.xib properties. MainWindow.xib属性。

在此输入图像描述

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.! 现在运行项目,您的项目将在Full iPhone 5屏幕或模拟器中运行。

在此输入图像描述

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 . 我已经创建了简单的应用程序存根来测试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. 我在Xcode 4.3.2中完成了它,没有Xcode 4.5.任何额外功能Xcode 4.5. And app automatically stretches its screen to proper size (for both portrait/landscape orientations). 并且app会自动将屏幕拉伸到适当的大小(适用于portrait/landscape方向)。

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上的“启动时全屏”选项为我修复了它。

No matter what I did, I could not get my app fullscreen. 不管我做了什么,我都无法全屏显示我的应用。

But after I added a file "Default-568@2x.png 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. 但是在我将一个文件“Default-568@2x.png”添加到我的应用程序之后。现在所有的xib都运行全屏。你可以通过在XCode中创建一个新的应用程序并复制创建的黑色png来快速测试。

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. 选择xib作为第一个屏幕。

did you try this? 你试过这个吗?

iOS Simulator > Hardware > Device > iPhone(Retina 4-inch) iOS模拟器>硬件>设备> iPhone(Retina 4英寸)

i just run into the same problem and this is how i solved. 我遇到了同样的问题,这就是我解决的问题。

How are you adding the main viewController to the window? 你是如何将主viewController添加到窗口的? 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. 首先,如果您在代码中构建初始视图,请确保使用window.rootViewController将初始视图添加到窗口,而不是简单地将视图添加为子视图的旧方法。 If you don't do this, autorotating will not work at all for your app under iOS 6. 如果您不这样做,自动旋转将完全不适用于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

Delete App on simulator by LongPress-ing and re-run. 通过LongPress并在重新运行的模拟器上删除应用程序。

This works for me, after 4 inch retina adjustments. 经过4英寸视网膜调整,这对我有用。 Everything was auto-resized the way I stitch-up in IB. 一切都是按照我在IB中拼接的方式自动调整大小。

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

We ran into a similar issue on an app that was created back in the iOS 6 days when testing on iOS 8. 我们在iOS 8上测试的iOS 6天内创建了一个类似的问题。

The fix for us was setting the "Hidden" flag on MainWindow.xib. 我们的修复是在MainWindow.xib上设置“隐藏”标志。

This is how we found out about the fix here . 这就是我们在这里发现修复的方法。

The same was happening to me. 同样的事情发生在我身上。 I was trying to make a video splash screen, and since I can't control the time the splash screen is shown, and was therefore unable to show the full video, I had to make a fake splash screen, which was just a controller that was shown first and then removed. 我试图制作一个视频启动画面,由于我无法控制启动画面的显示时间,因此无法显示完整的视频,我不得不制作一个假的启动画面,这只是一个控制器,首先显示然后删除。 That controller's view was not being shown as fullscreen no matter what I tried. 无论我尝试什么,该控制器的视图都没有显示为全屏。 In the end, I found out it was happening because I had no splash image. 最后,我发现它发生了,因为我没有飞溅图像。

Solution: Add splash screens to your project (even if they are just black images), and the full screen problem should be fixed. 解决方案:在项目中添加启动画面(即使它们只是黑色图像),应修复全屏问题。

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

相关问题 我的按钮在iPhone(4英寸视网膜)模拟器上未检测到触摸事件,但在iPhone(3.5英寸视网膜)模拟器中有效 - My button doesn't detect touch events on iPhone (Retina 4-inch) simulator, but works in iPhone (Retina 3.5-inch) simulator UIview布局无法针对iPhone视网膜4英寸屏幕自动调整大小 - UIview layout not autosizing for iPhone retina 4 inch screen 此代码仅适用于iPhone Retina 4英寸模拟器 - This code only works on iPhone Retina 4-inch simulator 提取联系人在iPhone Retina 4英寸64位模拟器中不起作用,但在3.5英寸中可以正常工作 - Fetching contact is not working in iphone retina 4inch 64bit simulator but works fine in 3.5 inch 为什么我的Xcode4.5没有iPhone(Retina 4英寸)和iPhone(Retina 3.5英寸) - Why my Xcode4.5 doesn't has iPhone(Retina 4-inch) and iPhone(Retina 3.5inch) 使用iPhone 5全屏播放非视网膜游戏 - Using iPhone 5 full screen for non retina game iPhone 5 4英寸屏幕更新 - iPhone 5 4 Inch Screen Update 在iPhone 4英寸屏幕上,它在模拟器中显示3.5英寸屏幕。 请检查屏幕截图。 可能是什么问题? - In iPhone 4inch screen, it shows up 3.5inch screen in simulator. Please checkout the screen shot. What may be the issue? iPhone 3.5英寸屏幕 - 4英寸屏幕: - iPhone 3.5 Inch screen - 4 inch screen: 在屏幕上安装iPhone 5模拟器吗? - Fitting the iPhone 5 simulator on my screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM