Closed xtnguyen closed 5 years ago
Thanks @xtnguyen for raising this issue! Probably the problem is that you haven't set the delegate to the peek implementation. Also, you need to only initialize the delegate implementation once (In your code you're initializing the delegate
it 4 time and setting a different property. What this code will do is that it will only set the cellPeekWidth
and won't set the number of items and the cell spacing). I'll write the example for the mapCollectionView
and you can do the same for the shortcutCollectionView
:
mapCollectionView.configureForPeekingDelegate()
delegate = MSPeekCollectionViewDelegateImplementation(cellSpacing: 5, cellPeekWidth: 5, numberOfItemsToShow: 3)
delegate.delegate = self //Missing Piece
mapCollectionView.delegate = delegate
mapCollectionView.dataSource = self
I hope this fixes your problem!
Thanks a lot for the solution @MaherKSantina, it worked out for the function didChangeActiveIndex that is now recognised however the disSelectItemAt still doesn't work, do you have any idea of the missing implementation ?
Haha no worries mate @xtnguyen ! For the selection call, it should work if the other one worked because they're part of the same delegate. This delegate call will only be triggered when you're tapping on a cell after the scrolling has stopped. If you click on a cell when the scroll is still moving it will not capture the selection. Also make sure that you have user interaction enabled (If you've previously disabled it)
Interestingly it doesn't seem to work and i have user interaction enabled on both, it's pretty weird. And in your swift file i don't see any implementation of the didSelectProtocol on did ChangeActiveIndex.
` extension MapViewController: MSPeekImplementationDelegate {
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int) {
print("Changed connard \(activeIndex)")
}
func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath) {
print("Selected item at \(indexPath)")
}
} ` I've followed the exact implement in the readme
Hmmm that's weird.. I'm trying it in the example project and it's working fine. Do you have a specific hierarchy set up? Like having the collection view inside a scroll view or table view or something? Maybe the tap is not being registered? (I'm not sure how it might affect it but I'm out of options 😢 )
Ohh and maybe if you could try on different simulator versions/iOS versions? And probably on a real device? I'm sorry mate I know all of this might be useless but It's the only stuff I can think of 😢
The collectionView is inside on a classic view controller that has googlemaps in it so I don't think it's a hierarchy problem... And i've only been testing on real devices so i don't really get where the problem is coming from :( I've tried giving the collectionView a normal delegate and the click works fine that's what I don't get.. No worries mate, i'll try to figure it out and if I find a solution will post it.
Ohh hmmm...Have you tried to add breakpoints inside the pod delegate calls to see if they're actually being called?
In my delegate the only public protocol that is available is the following : `public protocol MSPeekImplementationDelegate: AnyObject { func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didChangeActiveIndexTo activeIndex: Int)
}` So maybe the issue is there ?
Ohhhh now I understand what you meant by this:
And in your swift file i don't see any implementation of the didSelectProtocol on did ChangeActiveIndex.
The whole function is not in the delegate!
Which version of the MSPeekCollectionViewDelegateImplementation are you on? I think I've added the didSelect
delegate function not long ago! Make sure you are on version 1.2.1 and try to explicitly specify the pod version in the Podfile
pod 'MSPeekCollectionViewDelegateImplementation', '1.2.1'
And then execute
pod update
That explains it all my version was 0.13.0! Thanks again mate!
hahaha no worries glad I could be of help! Feel free to close the issue if everything has worked out for you! 👍👍
I've implemented my collection views this way :
and when calling func peekImplementation(_ peekImplementation: MSPeekCollectionViewDelegateImplementation, didSelectItemAt indexPath: IndexPath)
it seems like the function doesn't detect any of the collection vies that are implemented, swift doesn't seem to go through the function.. .
If you guys have any tips i'll be greatufull :)