tags:

views:

1274

answers:

5

I have many textfields in my Application which are in a scrollview.

What i need is when user touches on a textfield,

scrollview should scroll in such a way, so that that textfield should not be behind the keyboard.

i have seen these sample code site. but forgot. And right now I am not able to find it through google.

Help me.

thanks for your kind help to me.

+1  A: 

Maybe you could set the text fields' delegates to self, and then adopt the UITextFielDelegate protocol for the class, and then in this method:

- (void)textFieldDidBeginEditing:(UITextField *)textField

Make the scroll view scroll down enough so that you can see the text field.. I don't know how to make the scrollview scroll down though.

Mk12
+2  A: 

You can use the method - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated in UIScrollView, this should scroll to the offset of the point you give it, you will need to figure out the offset through code

Daniel
+3  A: 

Following link gives complete demonstration of the asked question

http://cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html

sugar
+1  A: 

I've written a tip that might be of help:

iPhoneDevTips.com - Adjust TextField Hidden by Keyboard

John

John
+2  A: 

I've written a pretty straightforward tutorial on doing this, it mimics as much as possible the behavior of Apple own applications, if it can be of any help:

Adjust UITextField hidden behind Keyboard with UIScrollView

muanis