A very simple problem but I have found no solution. How do I implement a UITextfield that increases in height as I type? This would be the type of control you see in iPhone's native SMS app send bar. When you press new line, the control increases in height.
+1
A:
I would use a UITextView instead. In either case you can use the TextDidChange notification (called editing changed in IB) to check the size of your text and update the height accordingly.
Jeremy
2009-09-30 23:08:19
+1
A:
In your UITextViewDelegate
implementation of textViewDidChange:
you need to calculate the size of the text for the specific width and adjust accordingly.
-(void)textViewDidChange:(UITextView *)textView
{
NSString *text = [textView text];
NSFont *font = [textView font];
CGFloat width = [textView frame].size.width;
CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(width, 9999) lineBreakMode:UILineBreakModeWordWrap];
/* Adjust text view width with "size.height" */
}
Nick Bedford
2009-09-30 23:17:32