Reputation: 1391
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.
Upvotes: 2
Views: 1063
Reputation: 124997
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.
Upvotes: 1