Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.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的自动布局失败_Ios_Ios7_Uilabel_Autolayout_Textkit - Fatal编程技术网

Ios 当没有单行接触左边缘时,UILabel的自动布局失败

Ios 当没有单行接触左边缘时,UILabel的自动布局失败,ios,ios7,uilabel,autolayout,textkit,Ios,Ios7,Uilabel,Autolayout,Textkit,我在UILabel中有一个NSAttribute字符串,如下所示: | Indented line | | Inde| | ted | | Line| 其中|标记UILabel的最大首选宽度。缩进行已使用段落样式属性缩进: NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init]; style.firstLineHeadIndent = 10; style.headI

我在UILabel中有一个NSAttribute字符串,如下所示:

|   Indented line            |
|   Inde|
|   ted | 
|   Line|
其中|标记UILabel的最大首选宽度。缩进行已使用段落样式属性缩进:

NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.firstLineHeadIndent = 10;
style.headIndent = 10:
结果是整个文本变得异常狭窄。大概是这样的:

|   Indented line            |
|   Inde|
|   ted | 
|   Line|
有两种方法可以“修复”此问题:

  • 如果我删除了段落样式,那么它就可以工作(没有缩进)
  • 如果我有一行没有段落风格的话
  • ==>

    对我来说,这两个都不是可行的解决方案。很难理解发生了什么,但autolayout显然觉得在这种情况下无法确定版面的宽度

    还有谁见过这个吗?有解决办法吗