解决方法参考 : http://stackoverflow.com/questions/25398312/automatic-preferred-max-layout-width-is-not-available-on-ios-versions-prior-to-8
重点摘要:
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.
这里是说,如果label设置了1行,那么可以根据字符串需要自动计算最大宽度的,
如果设置了多行,iOS8及以上可以支持自动计算宽度,但是小于iOS8的就不支持了,所以如果要支持到iOS7,就要显式(Explicit)的明确写上label所支持的最大宽度。
所以,如果工程要支持iOS7.0, 在多行的label,要选择勾选explicit并写上允许的最大值。
本文探讨了iOS中UILabel在不同版本下对于多行显示的支持情况。特别关注iOS8引入的自动计算preferredMaxLayoutWidth特性及其对iOS7及更早版本的影响。为确保良好的跨版本兼容性,建议开发者在使用多行UILabel时采取合适的设置。
1969

被折叠的 条评论
为什么被折叠?



