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

转载 2015年07月08日 10:38:16

專案 storybard 一直出現警告 Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0




經過元件一個一個刪除發現是 UILabel 的 使用了 Preferred Max Layout Width 這個屬性造成 numberOfLines 屬性只要不是  1 就會造成這個警告

P.S  這問題是 XCode6  才會出現的


將 Storyboard Builds 修改為 iOS 8.0






P.S 我使用修改 preferredMaxLayoutWidth 沒有辦法解決


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

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:

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" Xcode file inspector


Automatic Preferred Max Layout Width before iOS8.0 解决探索

项目中有时会出现这个警告”Automatic Preferred Max Layout Width before iOS8.0”,一般是在项目的xib文件(或storyboard中),这是Label的...

Auto Layout on iOS Versions prior to 6.0

使用XCODE5.0,出现这个小错误。。。 解决办法: 选中你的XIB或storyboard,如下图 再查看右边属性栏 ...

cocos2d-x 3.3连接Xcode9编译时报错:call to unavailable function system not available on ios

一个cocos2d-x 3.3的项目,使用Xcode8.3.2正常编译,但是连接Xcode9 beta编译时报错:call to unavailable function system not ava...
  • fzhlee
  • fzhlee
  • 2017-06-15 18:23
  • 3939

Not enough physical memory is available to power on this virtual machine with its configured setting


Xcode 8.0 调试运行,This ** is running iOS 10.1.1 (14B100), which may not be supported

2016年10月份 苹果升级了iOS系统为10.1,xcode 8.0 运行会提示: This iPhone 5 (Model A1429) is running iOS 10.1.1 (14B10...

Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

在tomcat的启动参数中加如:-Dforge.forceNoStencil=true,能解决下面问题,错误的关键信息为:# Failed to write core dump. Minidumps ...

今天试vi遇到的“Sorry,the command is not available in this version : syntax on”

想试试vi,试试配置,于是按照提示,在/home/xia下直接新建.vimrc文件 xia@ubuntu:~$vi .vimrc内容如下:    set number    set smarti...

net.sf.jasperreports.engine.util.JRFontNotFoundException: Font "黑体" is not available to the JVM. See

彻底解决linux上: 建个类 运行在linux上: class fonts{    public static void main(String[] args) throws Exceptio...

Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify pr

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService'...

Request caching is not available. Maybe you need to initialize the HystrixRequestContext?

在《spring cloud 微服务实战》书中第159页-----请求缓存这一部分,通过继承HystrixCommand的方式实现的命令,开启请求缓存只需通过重载getCacheKey()方法, @...