I’ve a customized header/footer class
class CustomCollectionReusableView: UICollectionReusableView {
var pageControl: UIPageControl!
...
}
and use it in UICollectionViewDataSource
applicable methodology:
func collectionView(
_ collectionView: UICollectionView,
viewForSupplementaryElementOfKind sort: String,
at indexPath: IndexPath
) -> UICollectionReusableView {
if sort == customKind {
...//return CustomCollectionReusableView object
}
...
}
The issue is that if I’ve a number of sections with the identical this header/footer then how ought to I get callback to know in which ones person clicked on pageControl
(get indexPath)?
If it was UITableViewCell
/UICollectionViewCell
subclass I may simply name a customized delegate in it with a cell-sender param after which name for instance collectionView.indexPath(for:)
.
The issue is there is no such thing as a such methodology for headers/footers. There’s collectionView.indexPathsForVisibleSupplementaryElements(ofKind:)
solely which returns a number of indexPath
objects.
Easy methods to resolve this difficulty accurately? Ought to I set callback block or indexPath inside this view?