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

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

问题描述

我在wAny hAny size类中设置约束,它在iPhone和iPad上工作。 iPad模拟器。

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

然后我切换到wAny hCompact size类并进行了一些修改

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?

推荐答案

思考我会发布这个,虽然汉娜的答案被接受,因为它可能对某人有用。您可以通过直接编辑源代码批量更新约束的大小类。通常一个坏主意,直接编辑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.

明显

查找以下节点:

Look for the nodes like:

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

在我的例子中,我想移植所有的紧凑宽度/紧凑高度'constraints to' Any Width / Compact Height ,并且通过使用空字符串查找/替换 -widthClass = compact heightClass = compact-widthClass = compact 改为 heightClass = compact

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".

源代码视图右键单击xcode中的storyboard文件,并选择'打开为>源代码'

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

在这个实例中非常简单,比在IB中做,因为我有很多约束更新。

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

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

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