警告:Attribute Unavailable Automatic Preferred Max Layout Width is not available on iOS versions pri
来源:互联网 发布:linux nano 保存 编辑:程序博客网 时间:2024/04/28 14:53
警告
Attribute Unavailable Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
原因
UILabel自动换行,在不同的iOS版本下表现不一致导致的UI问题
表现为在iOS7以上的系统中,UILabel能够自动换行,多行显示的字符串,而在iOS6上面则不会自动换行,直接打省略号。正常情况下,numberOfLines设置为0,UILabel就会自动换行了。
但是在iOS6下面需要设置preferredMaxLayoutWidth,autolayout才会判断到折行的位置,才能正确的显示多行的UILabel
解决方案
但是 preferredMaxLayoutWidth设置为多少才是正确的呢?
如果你知道一个确切的width当然是最好的,就可以按照最小屏幕宽度的 iphone4 来计算, 然后进行约束。
但是如果UILabel的宽度是自适应的,不确定,那么可以使用如下的代码设置:
- (void)layoutSubViews{ [super layoutSubViews]; self.label.preferredMaxLayoutWidth = self.label.bounds.size.width;}
当label已经显示到界面上的时候,那么宽度就已经确定了,可以直接用此宽度作为最大autolayout宽度设置。这样就正常了
相关文章: 警告:Automatic Preferred Max Layout Width before iOS8.0
0 0
- 警告:Attribute Unavailable Automatic Preferred Max Layout Width is not available on iOS versions pri
- Attribute Unavailable: Automatic Preferred Max Layout Width is not available on iOS versions prior t
- Attribute Unavailable: Automatic Preferred Max Layout Width is not available on iOS versions prior t
- Attribute Unavailable: Automatic Preferred Max Layout Width is not available on iOS versions prior t
- iOS自动布局解决警告Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- iOS自动布局解决警告Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- [Xcode] Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on iOS versions prior to
- [xcode-warning]Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- XCode自动布局Warning: Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
- Automatic Preferred Max Layout Width is not available on
- automatic preferred max layout width警告
- 警告:Automatic Preferred Max Layout Width before iOS8.0
- iOS自动布局解决警告Automatic Preferred Max Layout Width before iOS 8.0
- ios runtime 工作模式
- Android 输入法相关
- iOS常用的一些正则表达式代码举例
- Android Studio下导入jar包(以andbase.jar为例)
- ajax从后台向前台传数组
- 警告:Attribute Unavailable Automatic Preferred Max Layout Width is not available on iOS versions pri
- 缓存之 ACache
- Android中关于Volley的使用(三)认识Volley的架构
- Tomcat侧对request进行分析
- Lucas定理---组合数取模
- 蓝桥杯-取数游戏
- 硬盘的存储原理和内部架构
- oracle 一些特殊用法
- C#第6周实验类的继承