pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

Not scrolling back when new content arrives #55

Closed Kianoosh76 closed 7 years ago

Kianoosh76 commented 7 years ago

By default, when new content arrives, the bottomInset resets; so the scrollView scrolls up a bit and the only notification for new content is decrease length of scroll bar. I've changed this so the bottomInset won't reset and there is always a constant inset at the bottom of table, except when the scrollable content has been ended.


This change is Reviewable

pronebird commented 7 years ago

Hi @Kianoosh76,

Thank you for your PR. However I am not sure what problem you are trying to solve with it. Could you please elaborate a little more and help me to reproduce the issue that you experience?

Kianoosh76 commented 7 years ago

Hi again. I've uploaded two videos here. In the first video (1.mp4) you can see that when new content has been added to table view, the view scrolls upwards a bit so the new content moves completely behind the tab bar and becomes invisible, so there is no difference between this state and the state all content has been loaded or there an error occurred.

In the second video(2.mp4) you can see my how my change has acted by looking at the bottom of the table view and comparing it with the first one.

First video: https://www.dropbox.com/s/qribgzh65iesd9j/1.mp4?dl=0 Second Video: https://www.dropbox.com/s/4ka7fot9btlf5kh/2.mp4?dl=0 Thanks a lot for your attention

pronebird commented 7 years ago

Thanks for the screencast! Do you experience the same with the demo app coming with this component? I can't reproduce this issue in demo app. I wonder if there is something in your code that causes this or a bug in component.

Kianoosh76 commented 7 years ago

You're right! The demo app works as well! But I directly followed your instruction in the readme file of project! The only property I've changed was this:

tableView.infiniteScrollTriggerOffset = 5 * tableView.rowHeight

I wonder if this line caused the issue! BTW the demo app seems a bit customized and I (unfortunately) can't understand objective-c codes well.

pronebird commented 7 years ago

@Kianoosh76 Swift demo is available as well (https://github.com/pronebird/UIScrollView-InfiniteScroll/tree/master/InfiniteScrollViewDemoSwift). Try commenting out infiniteScrollTriggerOffset to see if it changes anything. We need to reproduce this issue.

Kianoosh76 commented 7 years ago

I changed the way I update table data and the issue weirdly disappeared! First, I used to reload entire table data; but when I used the method insertRows and only updated the new part of the table I saw no issue there! Seems weird!

pronebird commented 7 years ago

Yeah I think reloadData does not play nice with animations. Please use insertRow / deleteRow as they support animations.

Kianoosh76 commented 7 years ago

Ok thanks a lot!