IPhone: how to implement scroll behavior similar to iPhone SMS application

Possible duplicate:
How to make UITextField move up when the keyboard is present

I am trying to implement something very similar to the "chat like" screen of the iPhone sms application. Basically, it has a ScrollView with all message bubbles and a TextField at the bottom to record a new message.

When you click on a TextField element, a keyboard appears, and everything seems to scroll up so that the TextField is above the keyboard, rather than hiding it.

Apple documents suggest introducing a screen that should support the appearance of the keyboard using the ScrollView, which changes when the keyboard appears (while maintaining the same content). In my case, this would mean that I need a ScrollView so that it contains the entire chat screen (messages and TextField), so everything would be neatly changed to the appearance of the keyboard. However, messages are already in ScrollView, and this behavior is not supported.

The only choice that I see, somehow implements the customization behavior on its own, without using an external ScrollView. But it would look like very fine coding for scrolling and resizing animations of both message bubbles and TextField to work fine.

What should I do?

+6
iphone uiscrollview
source share
1 answer

Scrolling resizing is effectively done manually, checking the height of the keyboard and shortening the scroll in height.

In the case of the SMS screen, the text field is not in the scroll, so you just have a scroll sitting above the uiview that contains the send bits. When the keyboard appears, you shorten the scroll in normal mode and shift the uiview to the same keyboard height.

There is nothing magical about reducing scrolling, as Apple suggests: moving views is just as easy and smart.

+2
source share

All Articles