Created
July 19, 2016 21:40
-
-
Save thornpig/d22148323f38095865742f9254d2e9a5 to your computer and use it in GitHub Desktop.
Setting contentInset of scrollView makes it jump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The cause of this problem is when the contentInset is set, contentOffset is also set to a value according to the new value of contentInset. | |
So restore contentOffset to its old value after setting contentInset solves the problem. | |
It seems the animation block is not needed in my app with iOS 9.0. | |
- (void)setLoadingScrollViewInsets:(UIScrollView *)scrollView | |
{ | |
UIEdgeInsets loadingInset = scrollView.contentInset; | |
loadingInset.top += self.view.frame.size.height; | |
CGPoint contentOffset = scrollView.contentOffset; | |
[UIView animateWithDuration:0.2 animations:^ | |
{ | |
scrollView.contentInset = loadingInset; | |
scrollView.contentOffset = contentOffset; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment