自动preferred最大宽度的布局上没有的iOS之前的版本8.0 [英] Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

查看:173
本文介绍了自动preferred最大宽度的布局上没有的iOS之前的版本8.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开带有X $ C $ 6 beta6现有的iOS项目,X code列出两个故事板和XIB文件以下警告:


  

自动preferred最大宽度的布局上没有的iOS版本
  之前的8.0


我试图通过设置宽度明确如下图所示解决警告:

然而,这并没有解决警告。他们如何去除?


解决方案

更新3:结果
这个警告也可以通过已 numberOfLines 设置为任何东西,但1,如果您的部署目标设为7.1标签触发。这是新的单一视图项目完全可重复的。

重现步骤:


  1. 创建一个新的单一视图,Objective-C的项目

  2. 将部署目标为7.1

  3. 打开项目的故事板

  4. 挂断标签上提供的视图控制器

  5. 设置为标签numberOfLines为2。

  6. 编译

我提出的跟踪雷达:结果
rdar://问题/ 18700567

更新2:结果
不幸的是,这是第X code 6.注意的发行版,你可以,在大多数情况下,手动编辑情节提要/厦门国际银行来解决问题又来了一件事。每查尔斯A. 在下面的意见:


  

这是值得一提的,你可以pretty容易意外
  介绍这个警告,警告本身并没有找到帮助
  标签是罪魁祸首。这是在一个复杂的不幸
  故事板。您可以打开故事板作为源文件和搜索
  与正则表达式的 ≤(?!。* preferredMaxLayoutWidth)标签 找到的标签,
  省略preferredMaxLayoutWidth属性/值。如果您在添加
  preferredMaxLayoutWidth =0这样的行,它是相同的标记
  明确和设定值0。


更新1:结果
此bug已被固定在X code 6 GM。

原来的答案结果
这是X code6-Beta6和X code6-同β7的错误,可以安全地忽略了。

在苹果开发者论坛,苹果公司的工程师已经要说一下的bug:


  

preferred最大宽度布局上的UILabel自动布局属性,
  使得它能够自​​动增长垂直,以适应其内容。
  6.0之前将设置preferredMaxLayoutWidth为X $ C $的C版本
  多行标签在设计时的当前范围大小。你会
  如果需要手动在运行时更新preferredMaxLayoutWidth您
  横向布局更改。


  
  

8 iOS版增加了自动计算支持
  preferredMaxLayoutWidth在运行时,这使创建多行
  标签更容易。此设置不与iOS向后兼容
  7.支持的iOS 7和iOS 8,X code 6允许您选择为自动或显式为preferredMaxLayoutWidth的大小
  检查员。你应该:


  
  

如果针对iOS的8以获得最佳体验选择自动。挑
  明确的,如果目标< iOS的8.然后可以输入的值
  preferredMaxLayoutWidth你想设置的。启用显性
  默认为当时的电流界限大小您选中该复选框。


  
  

如果(1)您在使用自动布局将出现警告,(2)
  自动设置为一个多标签[您可以在此检查
  对于标签尺寸检查],和(3)的部署目标< iOS版8。


  
  

似乎错误是,此警告出现非自动布局
  文档。如果您看到此警告,而不是使用自动布局
  可以忽略警告。


另外,也可以解决此问题通过使用问题和变化的故事板或XIB文件检查器为构建到构建适用于iOS 8.0及更高版本

I opened an existing iOS project with Xcode6 beta6, and Xcode lists the following warning for both Storyboard and Xib files:

Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0

I tried addressing the warning by setting the width as explicit like below:

Yet this didn't resolve the warnings. How can they be removed?

解决方案

Update 3:
This warning can also be triggered by labels that have numberOfLines set to anything but 1 if your deployment target is set to 7.1. This is completely reproducible with new single-view project.

Steps to Reproduce:

  1. Create a new single-view, objective-c project
  2. Set the Deployment Target to 7.1
  3. Open the project's storyboard
  4. Drop a label onto the provided view controller
  5. Set the numberOfLines for that label to 2.
  6. Compile

I've filed the following radar:
rdar://problem/18700567

Update 2:
Unfortunately, this is a thing again in the release version of Xcode 6. Note that you can, for the most part, manually edit your storyboard/xib to fix the problem. Per Charles A. in the comments below:

It's worth mentioning that you can pretty easily accidentally introduce this warning, and the warning itself doesn't help in finding the label that is the culprit. This is unfortunate in a complex storyboard. You can open the storyboard as a source file and search with the regex <label(?!.*preferredMaxLayoutWidth) to find labels that omit a preferredMaxLayoutWidth attribute/value. If you add in preferredMaxLayoutWidth="0" on such lines, it is the same as marking explicit and setting the value 0.

Update 1:
This bug has now been fixed in Xcode 6 GM.

Original Answer
This is a bug in Xcode6-Beta6 and XCode6-Beta7 and can be safely ignored for now.

An Apple engineer in the Apple Developer forums had this to say about the bug:

Preferred max layout width is an auto layout property on UILabel that allows it to automatically grow vertically to fit its content. Versions of Xcode prior to 6.0 would set preferredMaxLayoutWidth for multiline labels to the current bounds size at design time. You would need to manually update preferredMaxLayoutWidth at runtime if your horizontal layout changed.

iOS 8 added support for automatically computing preferredMaxLayoutWidth at runtime, which makes creating multiline labels even easier. This setting is not backwards compatible with iOS 7. To support both iOS 7 and iOS 8, Xcode 6 allows you to pick either "Automatic" or "Explicit" for preferredMaxLayoutWidth in the size inspector. You should:

Pick "Automatic" if targeting iOS 8 for the best experience. Pick "Explicit" if targeting < iOS 8. You can then enter the value of preferredMaxLayoutWidth you would like set. Enabling "Explicit" defaults to the current bounds size at the time you checked the box.

The warning will appear if (1) you're using auto layout, (2) "Automatic" is set for a multiline label [you can check this in the size inspector for the label], and (3) your deployment target < iOS 8.

It seems the bug is that this warning appears for non-autolayout documents. If you are seeing this warning and not using auto layout you can ignore the warning.

Alternately, you can work around the issue by using the file inspector on the storyboard or xib in question and change "Builds for" to "Builds for iOS 8.0 and Later"

这篇关于自动preferred最大宽度的布局上没有的iOS之前的版本8.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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