views:

36

answers:

2

Hi,

I want to implement a in-app chat view like the following pic. http://img408.imageshack.us/img408/4057/img0139.png

How can I implement the input bar? As I cannot found any resourece on internet.

Thanks.

Best,

Dante

A: 

Use a UITextView, check for new line character in textViewDidBeginEditing and increase the height of the text view (and the background view if you have one).

lukya
but how can I make a toolbar like that one in the pic that autoresize to the height of the textview? Thanks
Dante
Add a UIView/UIImageView behind the text view and resize it when you resize the text view. I don't think the bar in the picture is a standard iPhone toolbar.
lukya
I can increase the height when the user press return but how can I reduce the height by deleting line?
Dante
A: 

Don't count newline chars, since you will miss lines added by long sentences, but use NSString's sizeWithFont methods. See http://stackoverflow.com/questions/406226/documentation-for-nsstring-sizewithfontforwidthlinebreakmode-method-in-the-ip

Then resize all elements appropriately (no, this will not happen by itself, you have to do it).

mvds