我有一个简单的textView动态填充数据.我想在填充数据后调整textview的高度,以便我看不到垂直滚动,也不会剪切文本.
可以通过选择其中一个textView模式来完成它还是我需要programaticaaly吗?
您可以通过将以下几行代码添加到您的应用程序中来实现: -
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
Run Code Online (Sandbox Code Playgroud)
在textview的委托方法中实现此代码
- (void)textViewDidChange:(UITextView *)textView
{
// you might have to compare the frames if it needs changing as user might not have added an extra line
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4544 次 |
| 最近记录: |