Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.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
TTTAttributedLabel linebreakmode在iOS6中中断_Ios_Nsattributedstring_Truncation - Fatal编程技术网

TTTAttributedLabel linebreakmode在iOS6中中断

TTTAttributedLabel linebreakmode在iOS6中中断,ios,nsattributedstring,truncation,Ios,Nsattributedstring,Truncation,如果我在TTtatAttributedLabel示例应用程序“Espresso”中将linebreakmode设置为truncation tail,则所有内容看起来都应该在iOS 5模拟器中,但如果我在iOS 6模拟器中运行该应用程序,则文本在第一行之后被截断,尽管文本超过3行。行数设置为零。我错过什么了吗?当我在浓缩咖啡应用程序中注意到这种行为后,我就可以不再担心我自己的应用程序中的代码会被破坏。 有什么建议吗?谢谢 iOS 6中的标签和文本视图支持本地属性文本。因此,如果您不需要支持旧版本的

如果我在TTtatAttributedLabel示例应用程序“Espresso”中将linebreakmode设置为truncation tail,则所有内容看起来都应该在iOS 5模拟器中,但如果我在iOS 6模拟器中运行该应用程序,则文本在第一行之后被截断,尽管文本超过3行。行数设置为零。我错过什么了吗?当我在浓缩咖啡应用程序中注意到这种行为后,我就可以不再担心我自己的应用程序中的代码会被破坏。
有什么建议吗?谢谢

iOS 6中的标签和文本视图支持本地属性文本。因此,如果您不需要支持旧版本的iOS,您可以摆脱第三方控制。

我目前也面临同样的问题。在实际设置文本之前,请尝试设置LineBreakMode。例如:

TTTAttributedLabel* descriptionLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(20, 120, 280, expectedSize.height)];
descriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
descriptionLabel.numberOfLines = 0;
descriptionLabel.text = description;

奇怪的是,问题自行解决了。我不明白为什么这个问题会发生在iOS6模拟器上,但现在它可以在iOS6设备和模拟器上使用NSLineBreakTailTruncation


谢谢你的回复

在我的例子中,由于某种原因,下面的代码导致标签只显示一行。移除它有帮助 'self.attributedLabel.autoresizingMask=UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;'

你可以试一试

NSMutableAttributedString*mutableAttributedString=[[NSMutableAttributedString alloc]initWithString:text];

[self.attributedLabel setText:mutableAttributedString在继承LabelAttributes和ConfiguringWithBlock:nil之后]

对不起,我理解错误。您可以尝试。-(void)setText:(id)继承LabelAttributes并配置WithBlock后的文本:(NSMutableAttributedString*(^)(NSMutableAttributedString*mutableAttributedString))block