I have implemented a collectionView inside a collectionView Cell. Lets name outer collectionView = collectionView(1) and collectionView inside cell = collectionView(2) There are scrolling images in collectionView(2).
collectionView(1) will scroll vertically and collectionView(2) will scroll horizontally.
collectionView(2) functions are presented in collectionView(1) Cell file.
My problem is that when I scroll the collectionView(1), the images got stuck in between of collectionView(2)
The following code is inside CollectionViewCell File.
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.imagesCount
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "HomePostImagesCollectionViewCell", for: indexPath)as! HomePostImagesCollectionViewCell
cell.image.image = UIImage(named: "\((indexPath as NSIndexPath).item % imagesCount)")
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
DispatchQueue.main.async {
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = mainStoryboard.instantiateViewController(withIdentifier: "OpenPostViewController")as! OpenPostViewController
let navigationController = UIApplication.shared.keyWindow?.rootViewController as! UINavigationController
navigationController.pushViewController(vc, animated: true)
}
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}