Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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)

share|improve this question

1 Answer 1

You need to put a new UIScrollView inside your UICollectionView since you should not mess with the zooming of the CollectionView itself.

share|improve this answer
    
Inside the UICollectionView? Or the UICollectionVIewCell? Sorry but it's not clear to me what you mean... Should i add the UIScrollView as a subview of the UICollectionView? Thank you – Phoenix Jun 20 at 2:42
    
Inside the cell – Nils Ziehn Jun 20 at 10:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.