IOS 11: scroll up when "adjustContentInset" changes with large headers?

I noticed that this code does not work as expected on iOS 11, because the value of the property adjusted byContentInset changes when the " navigationBar " is compressed while scrolling

CGFloat contentInsetTop=[scrollView contentInset].top;

if (@available(iOS 11.0, *))
{
    contentInsetTop=[scrollView adjustedContentInset].top;

}
////

[scrollView setContentOffset:CGPointMake(0, -contentInsetTop) animated:YES];

... for example, it can start as 140, and then decrease to 88for a minimum scroll offset. This means that if you call it, it does not actually scroll to the very top.

Besides saving the original offset in memory from the moment it was loaded UIScrollView, is there a way to restore this value later to ensure that it really scrolls to the top sequentially, regardless of the adjustedContentInset parameter ?

+6
source share
1 answer

Currently, there really is no way to do this with iOS 11, I heard. The only way to do this is to capture the initial value and save it for the duration of the navigation / view controller.

I will update my answer accordingly if I hear otherwise, but it will be torn in the basic version of iOS 11 forever, unfortunately.

+1
source

All Articles