vlasov / CCBottomRefreshControl

MIT License
319 stars 77 forks source link

Control appear after you navigate back #21

Open laindow opened 8 years ago

laindow commented 8 years ago

Hello guys,

I meet some issues with your controller. I have 2 screens with UICollectionView. I used your control on first screen. When I navigate to next screen and return back your control appear at the bottom. Don't need to do anything else - just go to next screen and return back.

Best regards, Konstantin.

abereghici commented 8 years ago

@laindow try this:

override func viewDidAppear(animated: Bool) {
        self.bottomRefreshControl.beginRefreshing()
        self.bottomRefreshControl.endRefreshing()
    }
aenhsaihan commented 7 years ago

The reason why this is happening is due to what's happening in this code:

- (void)brc_setContentOffset:(CGPoint)contentOffset {

    [self brc_setContentOffset:contentOffset];

    if (!self.brc_context)
        return;

    if (self.brc_context.wasTracking && !self.tracking)
        [self didEndTracking];

    self.brc_context.wasTracking = self.tracking;

    UIEdgeInsets contentInset = self.contentInset;
    CGFloat height = self.frame.size.height;

    CGFloat offset = (contentOffset.y + contentInset.top + height) - MAX((self.contentSize.height + contentInset.bottom + contentInset.top), height);

    if (offset > 0)
        [self handleBottomBounceOffset:offset];
    else
        self.brc_context.refreshed = NO;
}

The offset, which gets triggered if it gets larger than 30, is curiously triggered when I navigate to another screen. This presents a problem for me because more items are loaded onto the screen once the bottom refresh control is activated.

I've logged my observations below:

When I've reached the end of the screen:

contentOffset.y: 1979
(contentOffset.y + contentInset.top + height): 2562
(contentOffset.y + contentInset.top + height): 2562
Offset: 0

When I tap on a product:

contentOffset.y: 2043
(contentOffset.y + contentInset.top + height): 2626
(contentOffset.y + contentInset.top + height): 2626
Offset: 64

Why does the contentOffset.y go from 1979 to 2043 when navigating to another screen? @abereghici

aenhsaihan commented 7 years ago

I see what the original problem is. My problem might be different, but related. The original coder set the triggerVerticalOffset to 30, which might have been too low. But now that I've set it back to its default of 120, I am now experiencing the same problem as OP.

@abereghici I tried the fix you suggested. You still see the refresh control upon returning from navigation, but it does animate away.

I don't know which problem is worse at this point. Have more items load each time the user navigates to a different screen, or have the user see the bottom refresh control upon returning back from navigation. The user would find that weird and disorienting, but they would also be confused as to why they see more items without any input from him..