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

iOS 8 UILabel 自动布局警告

http://stackoverflow.com/questions/25398312/automatic-preferred-max-layout-width-is-not-available-on-ios-versions-prior-to-8

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

提供了一个基于51单片机的RFID门禁系统的完整资源文件,包括PCB图、原理图、论文以及源程序。该系统设计由单片机、RFID-RC522频射卡模块、LCD显示、灯控电路、蜂鸣器报警电路、存储模块和按键组成。系统支持通过密码和刷卡两种方式进行门禁控制,灯亮表示开门成功,蜂鸣器响表示开门失败。 资源内容 PCB图:包含系统的PCB设计图,方便用户进行硬件电路的制作和调试。 原理图:详细展示了系统的电路连接和模块布局,帮助用户理解系统的工作原理。 论文:提供了系统的详细设计思路、实现方法以及测试结果,适合学习和研究使用。 源程序:包含系统的全部源代码,用户可以根据需要进行修改和优化。 系统功能 刷卡开门:用户可以通过刷RFID卡进行门禁控制,系统会自动识别卡片并判断是否允许开门。 密码开门:用户可以通过输入预设密码进行门禁控制,系统会验证密码的正确性。 状态显示:系统通过LCD显示屏显示当前状态,如刷卡成功、密码错误等。 灯光提示:灯亮表示开门成功,灯灭表示开门失败或未操作。 蜂鸣器报警:当刷卡或密码输入错误时,蜂鸣器会发出报警声,提示用户操作失败。 适用人群 电子工程、自动化等相关专业的学生和研究人员。 对单片机和RFID技术感兴趣的爱好者。 需要开发类似门禁系统的工程师和开发者。
### 解决 Mac 上 VSCode 开发 Flutter 时提示 `dart:ui` 不可用的问题 在 Mac 上使用 VSCode 进行 Flutter 开发时,若出现错误提示 `dart:ui' is not available on this platform`,通常是由于编辑器未能正确识别 Flutter SDK 或项目配置不完整所致。要解决此问题,需要确保 VSCode 能够准确加载 Flutter SDK,并正确配置 Dart 插件的相关路径。 #### 1. 确保正确配置 `dart.flutterSdkPath` 在 `.vscode/settings.json` 文件中设置 `dart.flutterSdkPath` 为本地 Flutter SDK 的实际路径,例如: ```json { "dart.flutterSdkPath": "/Users/用户名/flutter" } ``` 若 Flutter SDK 安装在 `/Users/gege/flutterdev/flutter3.27.1`,则应配置为: ```json { "dart.flutterSdkPath": "/Users/gege/flutterdev/flutter3.27.1" } ``` 该配置确保 VSCode 使用指定的 Flutter SDK 版本加载项目,并能正确解析 `dart:ui` 等核心库[^1]。 #### 2. 使用 FVM(Flutter Version Management)配置 SDK 路径 如果项目使用 FVM 管理多个 Flutter SDK 版本,则应将 `dart.flutterSdkPath` 设置为项目本地的 FVM 版本路径: ```json { "dart.flutterSdkPath": ".fvm/versions/3.27.1" } ``` 这种方式允许每个项目独立使用不同的 Flutter SDK 版本,避免全局 SDK 切换带来的问题,并确保 `dart:ui` 等核心库能被正确识别[^1]。 #### 3. 验证 VSCode 插件与 SDK 的兼容性 确保已安装最新版本的 **Dart** 和 **Flutter** 插件,并通过命令面板运行 `Flutter: Run Flutter Doctor` 检查 SDK 路径是否被正确识别。若 Flutter Doctor 显示 SDK 路径无误,则可确认 VSCode 已正确加载 Flutter 环境。 #### 4. 检查 Flutter SDK 安装完整性 如果 `dart:ui` 仍然无法识别,可能是因为 Flutter SDK 安装不完整或损坏。可尝试重新下载并解压 SDK,或使用以下命令更新 SDK: ```bash flutter upgrade ``` 确保 SDK 中包含完整的 `dart:ui` 源码和相关依赖。 #### 5. 清理 VSCode 缓存并重启 有时 VSCode 的缓存可能导致 SDK 路径识别异常。可尝试删除 VSCode 的缓存目录并重启编辑器: - 删除路径:`~/Library/Application Support/Code` - 或者使用命令:`rm -rf ~/Library/Application\ Support/Code` 重启后重新加载项目,查看是否仍提示 `dart:ui` 不可用。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值