如何使 UITextView 像 Notes 应用程序一样使用文本展开
如何使 UITextView 随其内部的文本展开?
How can you make a UITextView expand with the text that is inside of it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何使 UITextView 随其内部的文本展开?
How can you make a UITextView expand with the text that is inside of it?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
你可以试试这个...
you could try this...
你可以试试这个..
You can try this..
你在 UITableView 中使用 UITextView 吗?
假设您在 UITableView 中使用 UITextView。为了使 UITextView 高度动态化(根据其中的内容),我们需要注意以下事项:-
确保正确给出 UITextView 约束。例如:我使用 XIB 作为 tableview 单元格,并且在单元格内部我有一个 UITextView。因此,我将对 UITextView 0 的所有四个边进行约束,例如:顶部、底部、前导、尾随。 (取决于您的要求)。
确保 UITextView 属性自动滚动已禁用。它应该关闭。
确保 TableView 单元格高度为 UITableView.automaticDimension
现在在“textViewDidChange”委托方法中,只需添加下面提到的代码:
现在,当您键入 init 时,您的 textView 将自动展开。
Are you using UITextView inside UITableView?
Let's suppose you are using UITextView inside UITableView. In order to make UITextView height dynamic(As per the content inside it) we need to take care of following things:-
Make sure UITextView constraints are properly given. e.g: I had used XIB for tableview cell and inside cell I had a UITextView. So, I will give constraint to UITextView 0 to all four sides e.g: Top, bottom, leading, trailing. (Depends on your requirements).
Make sure UITextView attribute, autoscroll is disabled. It should be off.
Make sure TableView cell height is UITableView.automaticDimension
Now inside your 'textViewDidChange' delegate method, Just add this below mentioned code:
Now your textView will auto expand, while you are typing init.