UIScrollView contentOffset jumps after animation - in 3.0 beta 5

I have a UIScrollView with multiple UITextFields on it. When the user edits the text field, it scrolls so that the UITextField is centered. The problem I'm running into is that the UIScrollView scrolls to the right place, but in the last frame of the animation it jumps to 300 300. It works fine in 2.2.1, but not in 3.0 beta 5. It always jumps exactly to 300 300. The weird thing is that when I call the returnScrollAfterEdit method, which moves the scroll view the same way it works, it works fine. Any ideas what might be causing this?

- (void) scrollViewToCenterOfScreen: (UIView *) field withKeyboard: (bool) withKeyboard {
    CGFloat viewCenterY = field.center.y;  
    CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
    CGFloat availableHeight = applicationFrame.size.height - 215;

    CGFloat y = viewCenterY - availableHeight / 2.0;

    NSLog ([NSString stringWithFormat: @ "w:% fh% f availH:% fy:% fx:% f", applicationFrame.size.width, applicationFrame.size.height, availableHeight, y, self.contentOffset.x]);

    if (y 
0


a source to share


2 answers


Fixed with version 3.0 version



0


a source


I'm not sure if this is exactly what you are looking for, but I had some crazy issues with the UITextView. It will scroll to the bottom of the frame if I were to select any text in the view. I fixed this by disabling scrollEnabled before adding text to the UITextView.

Thus, the code will look something like this:



[textarea setText:@""]; //blank out the text to scroll back to the top
[textarea setScrollEnabled:NO]; //disable to avoid scrolling
[textarea setText:@"new text here"]; 
[textarea setScrollEnabled:YES];
[textarea resignFirstResponder]; //to drop annoying blue

      

Hope this helps.

0


a source







All Articles