我想在我的UITextView
插入几个字符串,以便它们垂直显示
试过这段代码:
NSMutableString* examinationsString = [NSMutableString string];
for (NSString * examination in examinationsArray)
{
[examinationsString appendString:[NSString stringWithFormat:@"%@, %s ",examination, "\n"]];
}
return examinationsString;
我已将UITextView
Lines属性更改为5但仍然将所有内容更改为一行,用" /"
我做错了什么?
如果有超过1行,我还希望UITextView
延长,如果它当然没有自动实现
答案 0 :(得分: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;
答案 1 :(得分:1)
试试这个:
[examinationsString appendString:[NSString stringWithFormat:@"%@,\n",examination]];