简体   繁体   English

8.0之前的iOS版本上的属性不可用警告

[英]Attribute Unavailable warning on iOS versions prior to 8.0

What's causing this warning in the interface builder? 在界面构建器中导致此警告的原因是什么?

Attribute Unavailable Layout attributes relative to the layout margin on iOS versions prior to 8.0. 属性不可用布局属性相对于8.0之前的iOS版本的布局边距。

I'm using the XCode 6 Beta. 我正在使用XCode 6 Beta。 The warnings are pointing to lines in the xml source that do not concern attributes. 警告指向xml源中与属性无关的行。

Since I had already created the constraints, the answer was to click on the constraint, and then look in the Utilities bar (on the right). 由于我已经创建了约束,答案是单击约束,然后查看Utilities栏(右侧)。 As shown in the picture below, click on an item and then make sure that "relative to margin" is unchecked. 如下图所示,单击某个项目,然后确保未选中“相对于边距”。

相对于保证金截图

When you add constraints in Xcode 6, you have the option "Constrain to margins" which create a different constraint and can't be read, for example, in Xcode 5. Create the constraints without this options and the warnings should go away. 在Xcode 6中添加约束时,您可以选择“约束到边距”,它会创建不同的约束并且无法读取,例如,在Xcode 5中。创建没有此选项的约束,警告应该消失。 This constraints will be available on iOS 8. 此约束将在iOS 8上提供。

在此输入图像描述

If you have already created the constraints, we can change it clicking on the constraint and editing it. 如果您已经创建了约束,我们可以更改它,单击约束并进行编辑。 When selecting the second item, you can uncheck the "Relative to margin" option (as explained in the GLee answer. 选择第二项时,可以取消选中“相对于保证金”选项(如GLee答案中所述)。

If you can't find where the warning is coming from you can use this grep to find it. 如果找不到警告的来源,可以使用此grep查找。

Run this in Terminal in your project directory: 在项目目录的Terminal中运行它:

grep -C 6 -nr Margin .

The 6 says how many lines of context to show before and after the match. 6表示在比赛前后显示的上下文线数。

As per Gasper Kolenc opening the storyboard as Source Code is very useful. 根据Gasper Kolenc打开故事板作为源代码是非常有用的。 Here is a bit more info from my experience fixing this problem: 以下是我解决此问题的经验中的更多信息:

  1. In the storyboard source code search for "margin".You will see a line such as this. 在故事板源代码中搜索“margin”。你会看到这样的一行。

    constraint firstAttribute="trailingMargin" secondItem="Pgb-8w-IHT" secondAttribute="trailing" constant="8" id="nKP-uZ-7Xm"/ 约束firstAttribute =“trailingMargin”secondItem =“Pgb-8w-IHT”secondAttribute =“trailing”constant =“8”id =“nKP-uZ-7Xm”/

  2. Find the id of one of the attributes (Pgb-8w-IHT in the example above). 找到其中一个属性的ID(上例中的Pgb-8w-IHT)。

  3. Scroll up to find in which object this constraint belongs. 向上滚动以查找此约束所属的对象。 Something like: 就像是:

    tableViewCell contentMode="scaleToFill" selectionStyle="default" tableViewCell contentMode =“scaleToFill”selectionStyle =“default”

  4. Switch back to storyboard view and show the identity inspector window. 切换回故事板视图并显示身份检查器窗口。

  5. Search through the subviews of the object you found above to find the id (Pgb-8w-IHT) on the identity inspector. 搜索您在上面找到的对象的子视图,以在身份检查器上查找ID(Pgb-8w-IHT)。

  6. Once found inspect the constraints to find the one that needs to be deleted and recreated without the constrain to margins option selected (use the constant=" " as a hint". 一旦找到,就检查约束以找到需要删除和重新创建的约束,而不选择约束边距选项(使用constant =“”作为提示“)。

In my case, I had to uncheck the "Use Auto Layout" from my storyboard in the File Inspector, and redo all the constraints in my app, the old way with that shrinking / enlarging red rectangle. 在我的情况下,我不得不从文件检查器中的故事板中取消选中“使用自动布局”,并重做我的应用程序中的所有约束,旧的方式是缩小/放大红色矩形。

Size Classes were already disabled and the target is IOS 7.1. 大小类已被禁用,目标是IOS 7.1。

But think well if you have too many View Controllers, and had already made all your constraints. 但是如果你有太多的View Controllers,并且已经完成了所有约束,请好好想想。 When you disable auto layout, Xcode clears all the automatic constraints and reverts to the old model. 禁用自动布局时,Xcode会清除所有自动约束并恢复为旧模型。 Then you have to do all the job again. 然后你必须再做一切工作。

This was the only way I get rid of that Attribute Unavailable warning. 这是我摆脱属性不可用警告的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 属性不可用:8.0之前的iOS版本的第一个基线布局属性 - Attribute Unavailable: First baseline layout attribute on iOS versions prior to 8.0 警告:属性不可用:6.0之前的iOS版本上的最小字体比例 - warning: Attribute Unavailable: Minimum Font Scale on iOS versions prior to 6.0 警告:属性不可用:适用于iOS 3.0之前版本的iPhone SDK中的Content Edge Inset - Warning: Attribute Unavailable: Content Edge Inset in iPhone SDK for iOS versions prior to 3.0 自动首选最大布局宽度在8.0之前的iOS版本上不可用 - Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0 相对于8.0之前的iOS版本上的布局边距的布局属性 - Layout attributes relative to the layout margin on iOS versions prior to 8.0 类不可用。 在6.0之前的iOS版本上无法使用取消同步功能 - Class Unavailable. Unwind segues are not available on iOS versions prior to 6.0 禁止在8.0之前的iOS版本上使用“自动首选最大布局宽度”警告 - Inhibit `Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0` warnings 故事板警告:iOS 8.0之前的第一个基线布局属性 - Storyboard warning : First baseline layout attribute before iOS 8.0 警告:属性不可用 - Warning:Attribute Unavailable Xcode 5警告:属性不可用 - Xcode 5 Warning: Attribute Unavailable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM