“笔记”如何? iOS 联系人应用程序中实现的字段吗?
我需要创建与 iOS 联系人应用程序中的 notes 字段非常相似的内容。
有谁知道如何创建自动调整大小的效果。我假设该单元格左侧包含一个 UILabel
,右侧包含一个可编辑的 UITextView
。
我知道这个问题已经之前问过,但是发布的答案不够详细,我无法发表评论来询问更多细节。
欢迎任何想法。谢谢。
I need to create something very similar to the notes field in iOS Contacts application.
Does anyone know how to create the auto-resizing effect. I presume that the cell contains a UILabel
on the left and an editable UITextView
on the right.
I am aware that this question has been already asked before however the answer posted was not detailed enough and I cannot leave a comment to ask for more detail.
Any thoughts are welcome. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从接受的答案 到 此帖子。
您将设置一些对象(可能是表视图的委托)作为单元格中文本字段的委托。当文本视图委托收到
– textView:shouldChangeTextInRange:replacementText:
消息(或者可能只是-textViewDidChange:
)时,它可以计算文本视图所需的高度,如果如果与当前高度不同,请调用表的-reloadRowsAtIndexPaths:withRowAnimation:
方法。这将导致表重新加载行,从而有效地更改高度。Start with the accepted answer to this thread.
You'll set some object, possibly the table view's delegate, as the delegate of the text field in the cell. When the text view delegate gets a
– textView:shouldChangeTextInRange:replacementText:
message (or perhaps just-textViewDidChange:
) it can calculate the required height of the text view and, if that's different from the current height, call the table's-reloadRowsAtIndexPaths:withRowAnimation:
method. This will cause the table to reload the row, effectively changing the height.