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

More than 1 scrollview #42

Open
BlueBeetle13 opened this issue May 8, 2020 · 0 comments
Open

More than 1 scrollview #42

BlueBeetle13 opened this issue May 8, 2020 · 0 comments

Comments

@BlueBeetle13
Copy link

BlueBeetle13 commented May 8, 2020

Here is the current situation:

I have 2 tabs, and each has a UITableView using SwiftPulltoRefresh. In my case I am using a custom header but int shouldn't matter. You will notice that on the second UITableView created the pull to refresh won't work. The animation still happens but the refresh completion handler is never called. Also sometimes the content insets and offset are not properly reset.

This is because every instance of a scrollview points to the same header.

In UIScrollView+Extensions.swift you define:

private var headerKey: UInt8 = 0

Every time you reference spr_header you call objc_getAssociatedObject with the exact same key.

My quick and dirty solution was to define headerKey as:

private var headerKey: UInt32 = 0

and in spr_setCustomHeader:

public func spr_setCustomHeader(_ header: RefreshView) {
headerKey = UInt32(arc4random())
self.spr_header = header
}

Now each scrollview has a unique key for each header and there are no more issues. You need to do this for footerKey and tempFooterKey as well.

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

1 participant