Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSPeekImplementationDelegate returning nil #29

Closed
JhonnyTawk opened this issue Dec 24, 2018 · 4 comments
Closed

MSPeekImplementationDelegate returning nil #29

JhonnyTawk opened this issue Dec 24, 2018 · 4 comments

Comments

@JhonnyTawk
Copy link

I want to get the active index i implemented MSPeekImplementationDelegate the implementation is correct I already double checked everything The
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int) is not being called.
This is my implemetation:

peekImplementation = MSPeekCollectionViewDelegateImplementation()
       collectionView.configureForPeekingDelegate()
       peekImplementation.delegate = self
       peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: 0, cellPeekWidth: 0, scrollThreshold: 1, maximumItemsToScroll: 5, numberOfItemsToShow: 1)
       collectionView.delegate = peekImplementation
       collectionView.dataSource = self
@MaherKSantina
Copy link
Owner

Hello @JhonnyTawk, thank you for raising this issue. In the code snippet you provided you're initializing the peekImplementation variable twice (On the first line and on the 4th line). So after you're initializing it the second time you're not setting the delegate so that's why it's nil

@JhonnyTawk
Copy link
Author

even like this didn't work :

peekImplementation = MSPeekCollectionViewDelegateImplementation()
        collectionView.configureForPeekingDelegate()
        peekImplementation.delegate = self
        peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: 0, cellPeekWidth: 0, scrollThreshold: 1, maximumItemsToScroll: imagesArray.count, numberOfItemsToShow: 1)
        collectionView.dataSource = self

@MaherKSantina
Copy link
Owner

Hello @JhonnyTawk, you are still initializing the peekImplementation twice (On the first line and on the 4th line). If you comment out either the first line or the 4th line it should work.
The reason it's nil is because you're setting the delegate and then replacing the peekImplementation with a totally new instance by doing peekImplementation = MSPeekCollectionViewDelegateImplementation(cellSpacing: 0, cellPeekWidth: 0, scrollThreshold: 1, maximumItemsToScroll: imagesArray.count, numberOfItemsToShow: 1)

@JhonnyTawk
Copy link
Author

Thank you 👍

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

No branches or pull requests

2 participants