Getting the screen location of a cell from a UICollectionView

前端 未结 6 1433
野性不改
野性不改 2021-01-30 10:20

This isn\'t so much a question as an explanation of how to solve this problem.

The first thing to realize is that the UICollectionView does inherit from a <

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 11:15

    I've done this before as well. it took a while but it is possible.

    You need to use

    [currentImageView.superview convertRect:currentImageView.frame toView:translateView]
    

    Where currentImageView is the image that the user taps. It's superview will be the cell. You want to convert the rect of your image to where it actually is on a different view. That view is called "translateView" here.

    So what is translateView? In most cases it is just self.view.

    This will give you a new frame for your imageview that will meet where your image is on your table. Once you have that you can expand the image to take up the entire screen.

    Here is a gist of the code I use to tap an image then expand the image and display a new controller that allows panning of the image.

    https://gist.github.com/farhanpatel/4964372

提交回复
热议问题