2
votes

I have a UIScrollView that I'm scrolling using setContentOffset:animate:YES but if the device rotates I want to be able to stop it. Is this possible? Or how would I go about writing my own implementation of the setContentOffset with animation? thanks!

2

2 Answers

0
votes

scrollview.contentOffset = scrollView.contentOffset should stop the scrollView at its last scroll position.

Do this in willAnimateRotationTo..... in your viewController

If you have a UIScrollView sub-class you could do it in setFrame: , this is assuming the frame of the scrollview changes upon orientation change.

0
votes

try to use this instead:

[UIView animateWithDuration:.25 animations:^
{
    // replacement for setContentOffset:animated:
    self.scrollView.contentOffset = scrollPositionBeforeKeyboardAdjustments;
}];

if you are struggling with the keyboard, see my answer How to make a UITextField move up when keyboard is present?