简体   繁体   English

如何创建一个根据需要垂直扩展的 UITextView?

[英]How can I create a UITextView that expands vertically as required?

I am trying to create an iphone application where I need an expandable UITextView.我正在尝试创建一个需要可扩展 UITextView 的 iphone 应用程序。 I am looking for something similar to a feature in contacts app for adding notes.我正在寻找类似于联系人应用程序中用于添加笔记的功能的东西。

UITextView is a subclass of UIScrollView, so it should work to use the contentSize property to find out the dimensions of the content and resize the view accordingly. UITextView 是 UIScrollView 的子类,因此它应该可以使用contentSize属性来找出内容的尺寸并相应地调整视图的大小。 To properly react as the user edits, you should be able to use the delegate's textViewDidChange: method to trigger the size update.为了在用户编辑时做出正确反应,您应该能够使用委托的textViewDidChange:方法来触发大小更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM