UIPinchGestureRecognizer를 사용하여 이미지 주위의 확대/축소 및 패닝을 허용하는 모달 UIViewController의 모양을 트리거합니다. 기본적으로 하나의 이미지를 분리하고 더 자세히 탐색 할 수 있습니다.모달 UIViewController로 전환 제스처
새로운 UIViewController에는 자체 핀치 및 팬 제스처 인식기가 있습니다.
한 가지 단점은 새로운 UIViewController가 나타나면 사용자가 손가락을 화면에서 떼어 내고 새로운 제스처 인식기가 터치 이벤트를 식별하기 전에 다시 꼬집기 시작해야한다는 것입니다.
모달 UIViewController가 나타나면 사용자가 꼬집음 및/또는 팬을 계속할 수 있도록 완벽하게 핀칭을 적용하는 것이 이상적입니다. 새 UIViewController의 제스처 인식기가 트리거되는 방식으로 이전보기 컨트롤러에서 터치 이벤트를 모달 컨트롤러로 전환하는 방법이 있습니까?
내가 모달 확대보기 컨트롤러 트리거하는 데 사용할 코드:
- (IBAction)zoomImage:(UIPinchGestureRecognizer *)sender
{
// if the gesture was released while the scale factor is sufficiently big, show the modal view
if (sender.state == UIGestureRecognizerStateEnded && sender.scale > 1.6f) {
// prepare the modal view controller
ZoomViewController *viewControllerZoom = [[ZoomViewController alloc] initWithNibName:nil bundle:nil];
[viewControllerZoom setImage:self.imageViewImage.image andScale:sender.scale];
// present the modal view controller
[self presentViewController:viewControllerZoom animated:YES completion:nil];
// gracefully transition the image back to its original size
[UIView animateWithDuration:0.5f animations:^{
self.imageViewImage.transform = CGAffineTransformIdentity;
}];
}
else if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled) {
// revert to normal size on end
[UIView animateWithDuration:0.5f animations:^{
self.imageViewImage.transform = CGAffineTransformIdentity;
}];
}
else if (sender.scale >= 1.0f) {
// scale in place
CGFloat scale = sender.scale;
self.imageViewImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, scale, scale);
}
}
감사합니다. 귀하의 전략과 매우 유사합니다. 너무 힘들어서 어떻게 든 제스처를 유지할 수는 없지만 이것이 제대로 작동하는 것 같습니다. –