TwitterProfile icon indicating copy to clipboard operation
TwitterProfile copied to clipboard

Bottom view Scrolls to Top when tableview reloads and row height changed

Open mohanthakur92 opened this issue 3 years ago • 8 comments

@OfTheWolf I am using this library and i am using tableview in the bottomView i am having expand and collapse functionality when i expand and reload table the bottom view scroll ups and starts from top. Any solution is appreciated

mohanthakur92 avatar Sep 30 '20 10:09 mohanthakur92

@OfTheWolf can you please help me in this?

mohanthakur92 avatar Oct 05 '20 18:10 mohanthakur92

@mohanthakur92 Can you share a minimum sample project to replicate this please?

OfTheWolf avatar Oct 06 '20 10:10 OfTheWolf

@OfTheWolf ok i will share the sample code. Basically in the bottom tabs i used tableview and when i reload tableview and scrolls it tableview moves to top (its insets changes)

mohanthakur92 avatar Oct 06 '20 11:10 mohanthakur92

I believe it's caused by updateOverlayScrollContentSize in ContainerViewController, but my fix still not perfect.

bottom tableview/scrollview content size changed(estimatedRowHeight tableView when scrolls to bottom, or load more) --> overlayScrollView content size change --> overlayScrollView scrolls --> bottom tableview/scrollview scrolls(here causes Scrolls to Top even if revert contentOffset.Y, and drag scroll gesture will be interrupted)

CleanShot 2022-05-10 at 00 11 40
    private func updateOverlayScrollContentSize(with bottomView: UIView) {
        let contentOffsetY = overlayScrollView.contentOffset.y
        self.overlayScrollView.contentSize = getContentSize(for: bottomView)
        if contentOffsetY > 0 {
            // revert contentOffsetY after contentSize changes, but still not perfect
            self.overlayScrollView.setContentOffset(.init(x: 0, y: contentOffsetY), animated: false)
        }
    }

hstdt avatar May 09 '22 16:05 hstdt

@hstdt @mohanthakur92 I'm having same issue, did you guys solve it?

BH102 avatar Jul 12 '22 11:07 BH102

When I use table view with static cell size everything works fine but when I use table view with dynamic cell size, the scrolling is lagging specially when scrolling up

BH102 avatar Jul 12 '22 11:07 BH102

@hstdt @mohanthakur92 I'm having same issue, did you guys solve it?

No, you can try this one. https://github.com/pujiaxin33/JXPagingView

hstdt avatar Jul 13 '22 06:07 hstdt

@hstdt @mohanthakur92 I'm having same issue, did you guys solve it?

No, you can try this one. https://github.com/pujiaxin33/JXPagingView

Thank you, I've used it it's great

BH102 avatar Jul 17 '22 15:07 BH102