From 20f478f4e05548f2ac25aae72a2d8ef9ef087f10 Mon Sep 17 00:00:00 2001 From: Mikhail Stepkin Date: Thu, 6 Sep 2018 18:07:06 +0300 Subject: [PATCH] Fixed bug with disappearing on bounce cell (second from the last one in collection) --- Pod/Classes/PopupCollectonViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Pod/Classes/PopupCollectonViewController.swift b/Pod/Classes/PopupCollectonViewController.swift index 71d02e9..d3608e5 100644 --- a/Pod/Classes/PopupCollectonViewController.swift +++ b/Pod/Classes/PopupCollectonViewController.swift @@ -142,7 +142,7 @@ open class PopupCollectionViewController: UIViewController { self.popupCollectionView.reloadData() } - func didTapGesture(_ sender: UITapGestureRecognizer) { + @objc func didTapGesture(_ sender: UITapGestureRecognizer) { self.dismiss(completion: nil) } } @@ -363,6 +363,14 @@ extension PopupCollectionViewController: UICollectionViewDataSource { let vc = self.childViewControllers[indexPath.item] vc.view.removeFromSuperview() } + + public func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) { + let vc = self.childViewControllers[indexPath.row] + if vc.view.superview != cell { + vc.view.frame = cell.bounds + cell.addSubview(vc.view) + } + } } extension PopupCollectionViewController: UICollectionViewDelegateFlowLayout {