1

我想在 my 中插入几个字符串,UITextView以便它们垂直显示

试过这段代码:

NSMutableString* examinationsString = [NSMutableString string];

for (NSString * examination in examinationsArray)
{
    [examinationsString appendString:[NSString stringWithFormat:@"%@, %s ",examination, "\n"]];
}

return examinationsString;

我已将UITextViewLines 属性更改为 5,但仍将全部放在一行中,用“/”分隔

我究竟做错了什么?

UITextView如果有超过 1 行,我也希望拉伸,当然如果它没有自动实现

4

2 回答 2

2

请尝试以下代码:

NSMutableString* examinationsString = [NSMutableString string];

for (NSString * examination in examinationsArray)
{
    [examinationsString appendString:[NSString stringWithFormat:@"%@,\n",examination]];
}
return examinationsString;

现在UITextView根据视图调整大小contentSize

CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;
_textView.frame = frame;
于 2012-12-03T10:17:09.087 回答
1

试试这个:

[examinationsString appendString:[NSString stringWithFormat:@"%@,\n",examination]];
于 2012-12-03T10:14:54.347 回答