1
votes

I have added a scroll view to my view using IB. ScrollView contains text field and I scroll the UIScrollView programmatically upward when user taps on text field. My source code is below.

-(void)textFieldDidEndEditing:(UITextField *)textField{
     [inviteFriendScrollView setContentOffset:CGPointMake(0, 0) animated:YES];
}

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    [inviteFriendScrollView setContentOffset:CGPointMake(0, 30) animated:YES];

}

This code works fine on simulator but when I try this on the device (my device is iOS 5.0), scroll does not move upward or downward though above code executes. I have noticed that if I change animated:YES to animated:NO, the code works fine on device as well.

Can anyone please tell me why animated scrolling is not working on device?

Best Regards

2

2 Answers

0
votes

The only thing I found was if you set a breakpoint at textFieldDidBeginEditing and then continue, it tends to work more often than not. So it might be some timing bug with UIScrollView API animation.

0
votes

I had a similar problem - a UIScrollView working on simulator, but not working on device (iPad) when I attempted to debug it. It was fixed after I rebuilt the application (in XCode menu Product -> Clean, then Build).