SVPullToRefresh icon indicating copy to clipboard operation
SVPullToRefresh copied to clipboard

When using setCustomView, app freezes

Open bnetter opened this issue 12 years ago • 3 comments

Hey Sam,

Thanks for this great plugin. I'm facing a strange problem when using setCustomView though. I try to load a custom view from a xib file using this code:

    // Getting the views from the xib file
    NSArray *subviews = [[NSBundle mainBundle] loadNibNamed:@"MiscViews" owner:nil options:nil];

    for (UIView *subview in subviews) {
        if ([[subview restorationIdentifier] isEqualToString:@"Loading View"]) {
            // Creating a new view
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 150)];

            // Adding the subview form the xib to this view
            [view addSubview:subview];

            // Setting the new view as the view for the loading state
            [self.tableView.pullToRefreshView setCustomView:subview forState:SVInfiniteScrollingStateLoading];
        }
    }

But when the state is loading, the app freezes. From my researches, it's because layoutSubviews (from UIScrollView+SVPullToRefresh) is called repeatedly. Not sure why this happens, and my capacities to debug on Objective-C are kind of limited. I know this doesn't happen when I'm just creating a UIView directly from the code, without using a xib.

Has anyone been facing this problem before or has any idea why this happens?

bnetter avatar Mar 11 '14 10:03 bnetter

Ah, apparently this issue is reported there to: #169

bnetter avatar Mar 11 '14 11:03 bnetter

Tried to come back to a release that worked, and apparently this never worked well. When setCustomView was introduced, the problem was already here.

bnetter avatar Mar 11 '14 13:03 bnetter

Why are you using SVInfinite constants on the pull to refresh dialog?

RyanCopley avatar Oct 24 '16 16:10 RyanCopley