Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 属性化文本UILabel在UICollectionViewCell中截断,但在UITableViewCell中未截断_Ios_Xcode_Autolayout_Uicollectionview_Uilabel - Fatal编程技术网

Ios 属性化文本UILabel在UICollectionViewCell中截断,但在UITableViewCell中未截断

Ios 属性化文本UILabel在UICollectionViewCell中截断,但在UITableViewCell中未截断,ios,xcode,autolayout,uicollectionview,uilabel,Ios,Xcode,Autolayout,Uicollectionview,Uilabel,滚动后,UICollectionViewCell内的属性化文本UILabel将被切断(自动布局已启用) 为什么UITableViewCell中的相同设置工作正常。(约束/优先级也相同) 使用自定义字体和自动换行字型通过为UILabel属性preferredMaxLayoutWidth提供单元格宽度减去您在布局中使用的可能偏移量来解决此问题 self.yourUIlabel.preferredMaxLayoutWidth = CGRectGetWidth(self.bounds) - yourOf

滚动后,UICollectionViewCell内的属性化文本UILabel将被切断(自动布局已启用)

为什么UITableViewCell中的相同设置工作正常。(约束/优先级也相同)


使用自定义字体和自动换行字型

通过为UILabel属性preferredMaxLayoutWidth提供单元格宽度减去您在布局中使用的可能偏移量来解决此问题

self.yourUIlabel.preferredMaxLayoutWidth = CGRectGetWidth(self.bounds) - yourOffsets;
在这里找到了答案:

类似问题:

但仍然存在一些问题,为什么我在UITableViewCell中不需要这个属性