X $ C $ 6:有没有简单的方法来复制大小类之间的约束? [英] Xcode6: Is there any easy way to copy constrains between size classes?

查看:159
本文介绍了X $ C $ 6:有没有简单的方法来复制大小类之间的约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置限制在温妮HANY尺寸级别,和它的工作在iPhone和放大器; iPad的模拟器。

I setup constrains in wAny hAny size class, and it worked on iPhone & iPad simulators.

然后我切换到温妮hCompact大小类进行了一些修改

Then I switched to wAny hCompact size class and made some changes

这看起来iPhone横向模式好,但更改没有在iPad上,因为iPad是wRegular hRegular。我尝试应用这些约束来wRegular HANY尺寸级别,但无法找到一个快速的方法来做到这一点。这是没有意义再手动修改所有的约束。
我发现,如果我双击在检查面板中的约束,有安装约束到其他大小班的选择。但是,这只是一个单一的约束......

It looks good in iPhone landscape mode, but change nothing in iPad, because iPad is wRegular hRegular. I try to apply these constrains to wRegular hAny size class, but can't find a quick way to do that. It makes no sense to manually modify all the constrains again. I found that if I double click a constrain in Inspector panel, there's a option to install the constrain to other size classes. But this is only for a single constrain...

那么,是不是可以从一个尺寸应用类所有约束到另一个?

So, is it possible to apply all the constraints from one size class to another?

推荐答案

想我会发布此,即使汉纳斯的答案被接纳为它可能是用给别人。您可以批量通过直接编辑源$ C ​​$ C更新大小类的约束。一般一个坏主意,编辑IB直接生成XML,但我一直在使用好老查找执行更新和替换,它的救了我很多时间。

Thought i'd post this even though Hannes answer was accepted as it might be of use to somebody. You can bulk update the size classes for your constraints by editing the source code directly. Generally a bad idea to edit IB generated XML directly but I have performed an update using good old find and replace and it's saved me a lot of time.

免责声明明显 ,以防万一东西文件的备份去可怕的错误 ...

Obvious disclaimer: make a backup of the file in case something goes horribly wrong ...

查找节点,如:

<variation key="heightClass=(Size Class)-widthClass=(Size Class)">

在我的情况,我想移植到我所有的'紧凑型宽/紧凑型高度'约束'的任意宽度/紧凑型高度,并能够通过实现这一目标做一个查找/替换 -widthClass =紧凑为空字符串修改 heightClass =紧凑widthClass =紧凑只是 heightClass =紧凑

In my case I wanted to transplant all my 'Compact Width/Compact Height' constraints to 'Any Width/Compact Height', and was able to achieve this by doing a find/replace of '-widthClass=compact' with an empty string to change 'heightClass=compact-widthClass=compact' to just "heightClass=compact".

要获得源$ C ​​$ C查看右键单击X code中的故事板文件,然后选择打开方式>来源$ C ​​$ C

To get to source code view right click the storyboard file in xcode and select 'Open As > Source Code'

pretty在这种情况下简单,很多不是做它作为IB我有很多限制的更新更加容易。

Pretty straightforward in this instance and a lot easier than doing it in IB as I had lots of constraints to update.

这篇关于X $ C $ 6:有没有简单的方法来复制大小类之间的约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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