Skip to content

More than 1 scrollview #42

@BlueBeetle13

Description

@BlueBeetle13

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions