如何使用尺寸类使应用程序兼容iphone 5,iphone 6,iphone 6 plus [英] How to use size class to make app compatible to iphone 5, iphone 6, iphone 6 plus

查看:208
本文介绍了如何使用尺寸类使应用程序兼容iphone 5,iphone 6,iphone 6 plus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用尺寸等级来使我的应用兼容iPhone 5,iPhone 6和iPhone 6 plus。
我使用紧凑宽度常规高度:





这是使用xib或故事板并让其他东西留在iOS上的正确方法吗?
或者,我是否还需要添加其他一些东西?



它在所有设备中都能完美展示而不使用自动布局。



我是否需要做一些更改?
我是否需要在资源文件夹中添加3X图像?



最好的方法是什么?

解决方案

大小等级



查找下载示例项目。归功于斯坦福CS193课程。解释自动布局的视频是查看控制器生命周期,Autolayout ,您可以从 31:30 开始到 36:30 。但我强烈建议您查看整个视频以获得整体情况。


I am using size class for making my app compatible for iPhone 5, iPhone 6 and iPhone 6 plus. I am using compact width Regular height for this :

Is this the correct way for using the xib or storyboard and making the other things leave on iOS ? Or, do i need to have some other things needed to be added ?

It is showing perfectly in all devices without using Auto-layout.

Do I need to do some more changes ? Do i need to add 3X images in my resource folder ?

What is the best way to do the same ?

解决方案

Size classes

Looking up iOS Human Interface Guidelines, we can summarize

  • Portrait: iPhone4s, iPhone5, iPhone6, iPhone6 Plus all use Horizontal Compact, Vertical Regular.

  • Landscape: iPhone4s, iPhone5, iPhone6, all use Horizontal Compact, Vertical Compact.

    But iPhone6 Plus uses Horizontal Regular, Vertical Compact

  • iPad uses Horizontal Regular, Vertical Regular for both Landscape and Portrait


Image resolutions

According to this Official link, 3x image is needed for iPhone6 Plus. You can see the whole specs:


Best practice

Looks like your app only supports iPhone Portrait mode, in this case, your employment of Horizontal Compact, Vertical Regular is fine.

However, the best way to do it is to design your app with Horizontal Any, Vertical Any. If you have special case for some devices, for instance, iPad, which uses Regular for both Portrait and Landscape, you can adjust the views, layout constraints for it. The following two pictures show how the same view can have different layouts for different size classes.

  • View with Any Any size classes

  • The same view with Regular Regular size classes


Tricks

You can preview what you have done in storyboard using preview feature in xcode, the following steps show you how to do it:

  1. Layout all your views in storyboard with different size classes

  2. Click on the top right corner

  3. In the newly open window, click Preview here

  1. Click on the + button and select different device for previews.


Practice yourself

You can download a sample project here. The credit goes to Stanford CS193 course. The video which explains auto layout is View Controller Lifecycle, Autolayout and you can start from 31:30 to 36:30. But I highly recommend you to check the whole video to get the overall picture.

这篇关于如何使用尺寸类使应用程序兼容iphone 5,iphone 6,iphone 6 plus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆