PDA

View Full Version : About scrolling the view




iphonejudy
Dec 4, 2008, 06:01 AM
Hi,

I use the below code for scrolling the view

-(void)textFieldDidBeginEditing:(UITextField *)textField {
if( textField == textfield ) {
CGRect rc = [textField bounds];
UIScrollView* v = (UIScrollView*) self.view ;
rc = [textField convertRect:rc toView:v];
CGPoint pt = rc.origin ;
pt.x = 0 ;
pt.y=40;
[v setContentOffset:pt animated:YES];
[textfield becomeFirstResponder];
}

it scroll the page up,

1)I want to scroll down after enter the text in the text box.

Can anybody please tell me the code for scrolling down?
Regards
judy



jnic
Dec 4, 2008, 08:59 AM
scrollRectToVisible

It's right there in the UIScrollView docs:

https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/instm/UIScrollView/scrollRectToVisible:animated:

You might want to have a proper read through these, as most of your questions seem to be on the same theme:

https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKit_Framework/index.html