Any-Any大小类被ios7忽略 [英] Any-Any size class ignored for ios7

查看:178
本文介绍了Any-Any大小类被ios7忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iOS7和8 iPhone开发。
由于iOS7不支持紧凑高度大小的类,我认为解决这个问题的共识是使用任意大小的类来构建横向iPhone布局,
并使用纵向宽度常规纵向iPhone布局的高度(cWrH)大小等级。



我在any-any中为视图设置约束,然后将cWrH中的约束常量修改为特定于那个大小的班级。但是,iOS7设备以及Xcode预览会忽略任意约束,并对纵向和横向使用cWrH约束。



我不知道为什么这是发生。我想要做的就是根据方向设置不同的约束。



使用最新的Xcode 6.0.1可以轻松复制。



半相关:



希望这能解决您的问题。


I'm developing for both iOS7 and 8 iPhone. Since iOS7 doesn't support compact-height size classes, I thought the consensus way to go about this was to use the any-any size class for landscape iPhone layouts, and use portrait compact-width regular-height (cWrH) size class for portrait iPhone layouts.

I set a constraint on a view in any-any, then modify a constraint constant in cWrH to be specific to that size class. However, iOS7 device as well as Xcode preview ignores the any-any constraint, and uses the cWrH constraint for both portrait and landscape orientations.

I have no clue why this is happening. All I want to do is set different constraints depending on orientation.

This is easily replicated using latest Xcode 6.0.1.

Semi-related: How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?

Screenshots below:

解决方案

As per your question what you did is you have given leading,Top,height and width constraints in Any-Any Size Class.

So now its position will be fixed for any devices in landscape and portrait. Now when you changes size class to compact width and make changes in top constraints it will affect both portrait and landscape.

What you need to do using size class with Any-Any to place your controls in View controller and set those constraints which you would like to keep in both portrait and landscape.

e.g.: If you want to keep height and width fixed give those constraints in Any-Any Size Class.

Setting constraints in Any-Any Size Class will keep those constraints similar for both portrait and landscape.

1.) Setting leading and top constraints in portrait you can use width- Compact, height-Regular.

2.) Setting leading and top constraints in landscape you can use width- Any,height-Compact.

Visit link below it has the great explanation and your most of issues related to auto layout using size class will be solved:

http://mathewsanders.com/designing-adaptive-layouts-for-iphone-6-plus/

Hope this solves you problem.

这篇关于Any-Any大小类被ios7忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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