简体   繁体   English

Xcode 6自动为iPhone 6和6 plus调整应用程序大小

[英]Xcode 6 resizes app automatically for iPhone 6 and 6 plus

I was developing app in Xcode 5 for iOS 7 on iPhone 5 inch storyboard. 我正在iPhone 5英寸故事板上为iOS 7开发Xcode 5应用程序。 I prepared my app and its buttons, images and other stuff to fit iPhone 5 screen size, and then programmatically optimized app to fit iPhone 4 and 4s. 我准备了我的应用程序及其按钮,图像和其他东西,以适应iPhone 5的屏幕尺寸,然后编程优化的应用程序,以适应iPhone 4和4s。

And then Xcode 6 came, and two new devices, iPhone 6 and iPhone 6 plus. 然后是Xcode 6和两款新设备,iPhone 6和iPhone 6 plus。 I was thinking that i will have to spend few hours again to programmatically optimize app for those resolutions. 我想我将不得不再花几个小时来以编程方式优化这些决议的应用程序。

But i tried run my app on my new iPhone 6 and strange thing happened. 但我尝试在我的新iPhone 6上运行我的应用程序并发生奇怪的事情。 App itself made everything for me. 应用程序本身为我做了一切。 Everything was in right position and right size and i haven't done anything. 一切都在正确的位置和正确的大小,我没有做任何事情。

I saw that Xcode 6 now uses Size Classes to develop app for multiple devices. 我看到Xcode 6现在使用Size Classes为多个设备开发应用程序。

But i am not using Size Classes and Auto Layout in my project and it works? 但我没有在我的项目中使用大小类和自动布局,它有效吗?

I opened new project then. 然后我开了新项目。 In my new project resizing is not working like this anymore. 在我的新项目中,调整大小不再像这样工作了。 So it won't resize my buttons, views and other stuff automatically. 所以它不会自动调整我的按钮,视图和其他内容。

Has anyone have any idea what is happening? 有谁知道发生了什么?

If you don't use a launch story board or include launch images for the new iPhone 6 sizes, the entire screen will expand to fill the new device size (same thing happens when enabling Zoom in accessibility settings). 如果您不使用启动故事板或包含新iPhone 6尺寸的启动图像,整个屏幕将展开以填充新设备尺寸(启用放大辅助功能设置时会发生同样的事情)。 The iPhone 6 user will notice larger fonts, images, etc. iPhone 6用户会注意到更大的字体,图像等。

This is what's happening. 这就是发生的事情。 The problem is that you don't get to take advantage of extra screen real estate (extra pixels). 问题是你没有利用额外的屏幕空间(额外的像素)。 If that's cool with you, then keep it, but when you do finally optimize your app to use that extra real-estate the iPhone 6 users will suddenly complain that the font size has gotten smaller when it stops auto-zooming. 如果这对你来说很酷,那么请保留它,但当你最终优化你的应用程序以使用这个额外的空间时,iPhone 6用户会突然抱怨当停止自动缩放时字体大小变小了。

You should spend the time to optimize it for iPhone 6 and include launch images (or launch story board if supporting iOS 8+ only), and get the "Optimized for iPhone 6" note added to your app description. 您应该花时间为iPhone 6优化它并包括启动图像(或者如果仅支持iOS 8+,则启动故事板),并在您的应用程序描述中添加“Optimized for iPhone 6”注释。

To solve this issue and bring back the auto zoom for the applications, just do not set the Lauch screen file and put an image named Default-568h@2x.png (640x1136 pixels) in your project. 要解决此问题并恢复应用程序的自动缩放,只需不要设置Lauch屏幕文件并在项目中放置名为Default-568h@2x.png(640x1136像素)的图像。 Now make the entire project using iPhone SE screen size in the storyboard. 现在使用故事板中的iPhone SE屏幕大小制作整个项目。 When the application opens on the larger screen iphones, the view image will fill the entire screen. 当应用程序在较大的屏幕iphone上打开时,视图图像将填满整个屏幕。

If you don't touch your app pre iOS 8, it will automatically work in iPhone 6 and 6 Plus devices. 如果您在iOS 8之前未触摸您的应用程序,它将自动在iPhone 6和6 Plus设备中运行。 But if you want to use size classes (as you should), then you'll have to add the autolayout constraints to make things all good. 但是如果你想使用大小类(如你所愿),那么你必须添加自动布局约束来使事情变得更好。

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

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