uiscrollview 내에서 여러 이미지로 확대/축소 기능이있는 imageview를 사용하고 싶습니다. scrollview 내부에서 scrollview를 시도했지만 문제를 해결할 수 없습니다. 사진간에 스크롤하고 확대/축소하려는 경우 그 사진들.uiscrollview 내부의 사진 확대 및 축소
답변
나는 당신이 겪고있는 간단한 Github 프로젝트를 만들었습니다. 여기에서 확인하십시오 : https://github.com/twomedia/TMImageZoom
제스처 상태 변경을 처리하는 클래스를 만들어이 작업을 수행했습니다. 그런 다음 UIImageView를 창에 만들고 크기를 원본 이미지보기로 이동하여 사용자가 imageView를 확대/축소하는 효과를 만듭니다. 위 링크의 작은 스 니펫은 다음과 같습니다.
-(void) gestureStateChanged:(id)gesture withZoomImageView:(UIImageView*)imageView {
// Insure user is passing correct UIPinchGestureRecognizer class.
if (![gesture isKindOfClass:[UIPinchGestureRecognizer class]]) {
NSLog(@"(TMImageZoom): Must be using a UIPinchGestureRecognizer, currently you're using a: %@",[gesture class]);
return;
}
UIPinchGestureRecognizer *theGesture = gesture;
// Prevent animation issues if currently animating reset.
if (isAnimatingReset) {
return;
}
// Reset zoom if state = UIGestureRecognizerStateEnded
if (theGesture.state == UIGestureRecognizerStateEnded || theGesture.state == UIGestureRecognizerStateCancelled || theGesture.state == UIGestureRecognizerStateFailed) {
[self resetImageZoom];
}
// Ignore other views trying to start zoom if already zooming with another view
if (isHandlingGesture && hostImageView != imageView) {
NSLog(@"(TMImageZoom): 'gestureStateChanged:' ignored since this imageView isnt being tracked");
return;
}
// Start handling gestures if state = UIGestureRecognizerStateBegan and not already handling gestures.
if (!isHandlingGesture && theGesture.state == UIGestureRecognizerStateBegan) {
isHandlingGesture = YES;
// Set Host ImageView
hostImageView = imageView;
imageView.hidden = YES;
// Convert local point to window coordinates
CGPoint point = [imageView convertPoint:imageView.frame.origin toView:nil];
startingRect = CGRectMake(point.x, point.y, imageView.frame.size.width, imageView.frame.size.height);
// Post Notification
[[NSNotificationCenter defaultCenter] postNotificationName:TMImageZoom_Started_Zoom_Notification object:nil];
// Get current window and set starting vars
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
firstCenterPoint = [theGesture locationInView:currentWindow];
// Init zoom ImageView
currentImageView = [[UIImageView alloc] initWithImage:imageView.image];
currentImageView.contentMode = UIViewContentModeScaleAspectFill;
[currentImageView setFrame:startingRect];
[currentWindow addSubview:currentImageView];
}
// Reset if user removes a finger (Since center calculation would cause image to jump to finger as center. Maybe this could be improved later)
if (theGesture.numberOfTouches < 2) {
[self resetImageZoom];
return;
}
// Update scale & center
if (theGesture.state == UIGestureRecognizerStateChanged) {
NSLog(@"gesture.scale = %f", theGesture.scale);
// Calculate new image scale.
CGFloat currentScale = currentImageView.frame.size.width/startingRect.size.width;
CGFloat newScale = currentScale * theGesture.scale;
[currentImageView setFrame:CGRectMake(currentImageView.frame.origin.x, currentImageView.frame.origin.y, startingRect.size.width*newScale, startingRect.size.height*newScale)];
// Calculate new center
UIWindow *currentWindow = [UIApplication sharedApplication].keyWindow;
int centerXDif = firstCenterPoint.x-[theGesture locationInView:currentWindow].x;
int centerYDif = firstCenterPoint.y-[theGesture locationInView:currentWindow].y;
currentImageView.center = CGPointMake((startingRect.origin.x+(startingRect.size.width/2))-centerXDif, (startingRect.origin.y+(startingRect.size.height/2))-centerYDif);
// Reset gesture scale
theGesture.scale = 1;
}
}
을 설명 내가 사용자는 이제 사용자가 다음 이미지를 손가락을 리프트 경우의 finger.As을 해제 한 후 축소 이미지를 중지하려면 zoom zoom –
그리고이 제스처를 여러 이미지 뷰와 함께 scrollview에 추가하면 마지막 이미지가 확대됩니다.이 제스처를 scrollview 안에있는 모든 UIImageviews에 추가하면 스크롤 뷰의 마지막 이미지가 확대됩니다. –
시도해보기 전에 시도해보십시오.
- 1. uiscrollview 확대/축소 또한 하나의 확대/축소
- 2. MonoTouch에서 UIScrollView 확대/축소
- 3. UIScrollView + UIImageView 확대/축소
- 4. UIScrollView 확대/축소 및 GUI 관리
- 5. 확대/축소 무시 사진
- 6. 사진 확대/축소?
- 7. 연속 된 UIScrollView 확대/축소
- 8. UIRotationGestureRecognizer의 UIScrollView 확대/축소 문제
- 9. UIScrollView - 확대/축소 문제 (확대/축소 후 UIScrollView 내부 UIView의 맨 아래를 잘라냅니다.)
- 10. iOS 확대/축소 기능이있는 UIView/UIScrollView 오버레이
- 11. Objective-C에 대한 UIScrollview 확대/축소
- 12. UIScrollView 확대/축소 프로그램이 Exc_Bad_Access와 충돌 함
- 13. iOS - 스 와이프하여 위 확대/축소 UIScrollView
- 14. UIScrollView 특정 위치에서 핀치 확대/축소
- 15. 확대/축소 Core Graphics in UIScrollView
- 16. iPhone : 확대/축소 효과가있는 다중 UIImageView가있는 UIScrollview
- 17. 확대/축소 및 핀치 확대/축소 플러그인
- 18. UIScrollView 홀수 동작 : 확대, 축소, 축소, 내용보기 해제
- 19. UIScrollView 내 UIScrollView 내부의 UIScrollView
- 20. UIScrollView 내부의 UIScrollView 스크롤
- 21. UIScrollView 내부의 UIScrollView : 스크롤
- 22. 확대/축소 및 UIWebView
- 23. WPF에서 확대 및 축소
- 24. 확대 및 축소 Threejs
- 25. AS3 확대 및 축소
- 26. FlipView를 사용하여 집게 및 확대/축소 기능이있는 단순한 사진 앨범
- 27. UIScrollView 바운스 확대
- 28. pagingScrollView 내에서 확대/축소
- 29. 애니메이션으로 UIScrollView 확장 및 축소
- 30. UIScrollView 기반 컨트롤이없는 핀치 확대
는 질문에 노력 코드를 넣고 잠시 – arunjos007