Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setContentOffset/scrollRectToVisible works unexpected after infinite scroll handler invoked at least once #76

Open
Aft3rmathpwnz opened this issue Oct 15, 2018 · 7 comments

Comments

@Aft3rmathpwnz
Copy link

The same behaviour can be noticed in demo app: add leftNavBarItem "Up", which will handle tap as
tableView.setContentOffset(CGPoint(x: 0, y: -tableView.contentInset.top), animated: true)
for example. Scroll by finger to bottom, wait till fetching will be completed, then tap "Up" button and you will end up with messed contentOffset. When I was debugging this in my project I noticed that swizzled method pb_setContentOffset wasn't logging last values, i.e. contentSize was (375, 12000), contentOffset was (0, 6000), after setContentOffset (or scrollRectToVisivle with (0,0,tableView.frame.size.width, 1.0)) final log in pb_setContentOffset was like ±600, and it was the exact position according to View Debugger. Second tap when have an offset of 600 is driving contentOffset to be correct. Any thoughts or workarounds?

@pronebird
Copy link
Owner

That's super weird. Do you think it can be related to contentInsetAdjustmentBehavior introduced in iOS 11? I haven't got time to fix that :/

@Aft3rmathpwnz
Copy link
Author

Aft3rmathpwnz commented Oct 18, 2018

I don't think so, I can see the same behavior in iOS 10 too

@Aft3rmathpwnz
Copy link
Author

What else I can check to probably fix it?

@Aft3rmathpwnz
Copy link
Author

Another idea is that something is being set up/off incorrectly on the "load more" action when reaching the bottom of content because this contentOffset wrong value has a cumulative nature (i.e. if we "Go up" after only one "load more" we will have 150px mistake, if after 2 - 330, then 479 etc.) and after reaching contentOffset 0;0 by gesture or manuallty tapping "Go up" 2 times then we will have to perform "load more" to make this bug appear again.

@pronebird
Copy link
Owner

pronebird commented Oct 18, 2018

@Aft3rmathpwnz trying to reproduce this. I'll get back to you later.

Yeah alright I can reproduce this too. I'll add more logging around to see what and when breaks the animation.

@Aft3rmathpwnz
Copy link
Author

@pronebird Hey, the reason behind it was that I have a table view and was trying to set contentOffset instead of scrollToRowAtIndexPath:atScrollPosition:animated:. With the last one everything's okay (I got hint from your sources' comment). Why is this happening from technical perspective, do you know?

@pronebird
Copy link
Owner

@Aft3rmathpwnz I don't exactly recall, since it's been a long time ago when I touched this code last time. But perhaps it has something to do with self-sizing cells and auto-layout. Try disabling self-sizing cells in demo and see if you can reproduce the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants