问题
I'm having this issue. I change the scale and as well the transition of the view of a UICollectionViewCell
, for doing zoom in the position of my fingers do the UIPinchGesture. But after that, the position of the view changes and the view go off the screen and its bounds. I want that the Gesture View get back to its correct position.
This is what is happening:
I have tried to assign a CGAffineTransformIdentity
to the view if the center of the cell changes, but after the Scale
and the Translate
, its center always changes, so its frame
as well.
The code in UIGestureRecognizerStateEnded
:
if ([gesture state] == UIGestureRecognizerStateEnded){
//Get the Cell that is getting zoomed
CGPoint initialPinchPoint = [gesture locationInView:self.collectionView];
NSIndexPath* pinchedCellPath = [self.collectionView indexPathForItemAtPoint:initialPinchPoint];
SBQPhotosDetailCollectionViewCell *cell=[[SBQPhotosDetailCollectionViewCell alloc] init];
cell=(SBQPhotosDetailCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:pinchedCellPath];
//Check ifs frame with the gesture of the Pinch
if ((cell.frame.origin.x != [gesture view].frame.origin.x) || (cell.frame.origin.y != [gesture view].frame.origin.y)){
[gesture view].transform = CGAffineTransformIdentity;
}
}
I would like to apply the CGAffineTransformIdentity
only if the view of the Gesture
change its center
, position
, but not if the view
got zoomed
.
Thanks
来源:https://stackoverflow.com/questions/23269622/keep-uicollectionviewcell-centered-after-zooming-with-uipinchgesturerecognizer