Xcode 6 resizes app automatically for iPhone 6 and

2019-01-24 09:43发布

问题:

I was developing app in Xcode 5 for iOS 7 on iPhone 5 inch storyboard. 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.

And then Xcode 6 came, and two new devices, iPhone 6 and 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. 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.

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?

回答1:

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). The iPhone 6 user will notice larger fonts, images, etc.

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.

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.



回答2:

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. Now make the entire project using iPhone SE screen size in the storyboard. When the application opens on the larger screen iphones, the view image will fill the entire screen.



回答3:

If you don't touch your app pre iOS 8, it will automatically work in iPhone 6 and 6 Plus devices. 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.