【发布时间】:2010-12-21 13:46:57
【问题描述】:
UIlabel 具有 numberOfLines 属性。它说我的字符串有 2 行。但是当我使用 UItextview 时,我想根据 UITextview 中的文本长度来拆分行数。我该怎么做? UIlabel 自动拆分,但 UITextview 不这样做。
【问题讨论】:
标签: iphone uitextview uilabel
UIlabel 具有 numberOfLines 属性。它说我的字符串有 2 行。但是当我使用 UItextview 时,我想根据 UITextview 中的文本长度来拆分行数。我该怎么做? UIlabel 自动拆分,但 UITextview 不这样做。
【问题讨论】:
标签: iphone uitextview uilabel
行应该用“\r”隔开
这是一个例子:
lblNeedSubscription = [[UILabel alloc] initWithFrame:frame];
[lblNeedSubscription setNumberOfLines:0]; // allows as many lines as needed
[lblNeedSubscription setText:@"To access content\ryou need to be a paid subscriber"];
【讨论】:
UITextView 本质上允许多行文本。你只需用“/n”字符分隔你的行,你就完成了。
【讨论】: