“因特质而异";不能按预期工作 [英] "Vary for Traits" not working as expected

查看:57
本文介绍了“因特质而异";不能按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我的理解,的答案,您可以调整故事板中所需组件的大小,以确保发生问题的位置都正确.我有一个常规分辨率为353x229的图像,该图像在iPhone 4s屏幕上看起来很大,因此我只想在4s屏幕上将其尺寸调整为300x194,这就是我的操作方式:

From what I understand as explained in the answer to this question you can resize which ever component on the storyboard for any device that you want, well that right there is the where the problem occurs.. I have an image which the regular resolution of it is : 353x229 and this image looks huge on the iPhone 4s screen so I want to resize it to 300x194 only on the 4s screen and this is how I do it :

首先,我单击变化为特征"按钮,然后单击图像,然后单击右侧的显示尺寸检查器",然后从此处将宽度等于"更改为300,然后将高度等于"更改为"设置为194,然后单击完成变体".

First I click on the Vary for Traits button, then I click on the image and then click on the "Show the Size inspector" on the right side and from there I change the "Width Equals" to 300 and "Height Equals" to 194 and then I click on "Done Varying".

但是问题是每个设备的图像都会调整大小!甚至iPad!我不明白为什么会这样,我该如何阻止这种情况发生?

But the problem is the image is resized for every single device ! Even the iPad ! I don't understand why this is happening and how am I supposed to stop this from happening?

推荐答案

也许现在您已经弄清楚了.但是如果其他人有类似的问题,这是我的2美分:

Perhaps by now you have figured it out. But in case others have a similar problem, here's my 2 cents:

我面临着一个类似的问题:iPhone和iPad的标签需要具有不同的高度.但是,每当我使用针对不同特征的iPad改变标签上的高度时,它也会同时改变iPhone上的高度.

I was facing a like problem: a label needed to have a different height for iPhones and iPads. But every time I changed the height of the label on the iPad using vary for traits, it also changed the height on the iPhone.

这是我要解决的问题:

  1. 选择对象(在我的情况下为标签)
  2. 大小检查器 中,双击要为其他设备更改的约束
  3. 点击 常量 旁边的+号.
  4. 选择适当的特征(在我的情况下,选择iPad的常规高度和宽度)并添加变体.
  5. 现在,在常量"下拉菜单下,您现在将看到对应设备的不同布局.
  6. 您现在可以更改相应约束的大小.

请注意,您必须为每个需要更改的约束执行此操作.我意识到,通过选择所需的设备并点击 因特质而异 ,它也可以正常工作.但是我认为这是越野车,因此这是完成同一件事的另一种方法.

Please note that you have to do this for each constraint you need to change. I realise that it should also work by selecting the desired device and click Vary for Traits. But I think it's buggy and so this is an alternative way of accomplishing the same thing.

这篇关于“因特质而异";不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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