View the contents of a single cell in a UICollectionView

I am trying to achieve the same behavior as in the Photos application when one image is open in full screen; that is, I want to be able to scroll between my various images, as well as a pinch to enlarge any of them. As in the Photos application, after I enlarged the image to a specific image, I would like to scroll through various images of my gallery.

My situation is this: I have a UICollectionViewcustom one UICollectionViewFlowLayout, where itemSize is set as the screen size, and a custom UICollectionViewCellone that has UIImageView. This works very well, scrolling through different photos, the problem in them scrolls.

The first approach I tried is the one pictured at the WWDC 2012 session : 'Advanced collections and building custom layouts. The effect obtained with this approach is the correct scaling of the cell, but then it will overlap with the neighboring cells, creating an undesirable effect.

The second approach is similar to the one proposed in the WWDC 2010 session : “Developing applications with a scroll list. However, I'm not quite sure that this approach will work with UICollectionView instead of UIScrollView + subviews. I set my view controller to UIScrollViewDelegateoverride viewForZoomingInScrollView:, where I return the UIImageView of the visible cell at this given point. Nothing happens if I do it. I also tried to return the cell, and in this case the whole UICollectionView layout got messed up. I looked at a sample Apple project ( PhotoScroller ) that successfully implements that what i want but there he and just have UIImageViewas a peep UIScrollView.

, , "" UICollectionView, , , .

, , - .

+4
1

, , , , .

, , - UIScrollView UICollectionViewCell UIImageView UIScrollView. , , , , UIScrollViews AutoLayout, . , , , , , . UIImageView viewForZoomingInScrollView: , .

, , , , (.. 1.0). , .

+2

Source: https://habr.com/ru/post/1547735/


All Articles