Reputation: 181
How to zoom a UIImageView that takes up a fullscreen cell in a UICollectionView image?
Since UICollectionView is a subclass of UIScrollView it should be fairly simple..
I tried to set minimumZoomScale, maximumZoomScale and viewForZoomingInScrollView: but the result is a mess.
In viewForZoomingInScrollView i returned the UIImageView, but that does not work.
Now i'm trying to return the visualized cell, but on zooming the image changes to the first cell.
it zooms but messes up the collection view.
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
if let selectedIndex = self.collectionView.indexPathsForVisibleItems().last as? NSIndexPath
{
let cell = self.collectionView.cellForItemAtIndexPath(selectedIndex)
return cell
}
return nil
}
So, what i need to do to zoom the image (cell) currently on screen?
Moreover pagingEnabled goes off automatically (that's good for panning the zoomed image, but not for scrolling the collection)
Upvotes: 1
Views: 1513
Reputation: 4331
You need to put a new UIScrollView inside the cell of your UICollectionView since you should not mess with the zooming of the CollectionView itself.
Upvotes: 1