Skip to content
This repository was archived by the owner on Apr 16, 2021. It is now read-only.

Problem initializing with specific index #1

Open
freshking opened this issue Sep 8, 2014 · 2 comments
Open

Problem initializing with specific index #1

freshking opened this issue Sep 8, 2014 · 2 comments

Comments

@freshking
Copy link

I initialize and add the MHYahooParallaxView to my view controller in the viewDidLoad method.
This works just fine but I am not able to load right into a certain index. The only method I found to be working is to set setCurrentIndex: in the viewDidAppear method but this ways the user still sees the first index first and shortly after the selected index is loaded. Setting setCurrentIndex: in viewWillAppear: does not work.
Am I missing something or should this be a feature request?
Thanks!

@uzman
Copy link

uzman commented May 8, 2015

in MHYahooParallaxView.m class update the following:

  • (id)initWithFrame:(CGRect)frame withViewType:(MHYahooParallaxViewType) viewType{
    ....
    ....
    [self addSubview:_parallaxCollectionView];
    [self layoutSubviews]; // add this line
  • (void) setCurrentIndex:(NSInteger)index animated:(BOOL) animated {
    _currentIndex = index;
    // update below line
    [_parallaxCollectionView setContentOffset:CGPointMake(index * (_width + _separatorWidth), 0.0f) animated:animated];
    }

@djolereject
Copy link

Thank you for this tip, it works like a charm.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants