VGParallaxHeader icon indicating copy to clipboard operation
VGParallaxHeader copied to clipboard

setParallaxHeaderView multiple times using UIScrollView doesn't work

Open cerupcat opened this issue 10 years ago • 3 comments

I'm trying to update the view and height of a parallaxHeader. I'm calling setParallaxHeaderView every time to update it (since I don't see another method). However, when you try and call setParallaxHeaderView on a scrollView more than once, the offsets aren't taken into account and the header keeps moving down the page. I'm not exactly sure how to fix this or update/change the view and height.

You can test this by putting this in viewDidLoad of UIScrollView example:

 HeaderView *headerView = [HeaderView instantiateFromNib];

    [self.scrollView setParallaxHeaderView:headerView
                                      mode:VGParallaxHeaderModeCenter
                                    height:200];

    // Delay execution of my block for 10 seconds.
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

        HeaderView *headerView = [HeaderView instantiateFromNib];
        [self.scrollView setParallaxHeaderView:headerView
                                          mode:VGParallaxHeaderModeCenter
                                        height:200];
    });


    // Delay execution of my block for 10 seconds.
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

        HeaderView *headerView = [HeaderView instantiateFromNib];
        [self.scrollView setParallaxHeaderView:headerView
                                          mode:VGParallaxHeaderModeCenter
                                        height:200];
    });

    // Delay execution of my block for 10 seconds.
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{

        HeaderView *headerView = [HeaderView instantiateFromNib];
        [self.scrollView setParallaxHeaderView:headerView
                                          mode:VGParallaxHeaderModeCenter
                                        height:200];
    });

cerupcat avatar Oct 20 '15 01:10 cerupcat

Hi @cerupcat

I've seen this too and I've started a fix on my fork, but I didn't go deeper...

maxep avatar Oct 28 '15 12:10 maxep

Thanks @maxep. I'm using your MXSegmentedPager and it looks like you're using your repo version for this so that'll fix my issue. :)

cerupcat avatar Nov 03 '15 19:11 cerupcat

Actually, @maxep it looks like MXSegmentedPager isn't using your fork and therefore it has the same issue. Any chance of updating to use your fork instead? I'll make a ticket.

cerupcat avatar Nov 03 '15 20:11 cerupcat