2012-06-06 4 views
1

UIImageView가 포함 된 scrollview 내에서 단일보기 응용 프로그램을 만들고 있습니다. 이미지보기는 잡지 페이지이므로 제대로 확대/축소하고 스크롤 할 수있게하려면, 그래서 (사과의 tapToZoom 샘플 덕분에) 두드리기로 줌을 설정하면 모든 것이 잘 작동합니다.스크롤 뷰에서 손가락으로 확대/축소

문제는 내가 구현하기가 조금 더 힘들어 핀치로 줌을 포함하고 싶습니다.하지만 성공했는데 줌이 적절하지 않습니다. 줌인이 비늘처럼 보이고 또한 축소했을 때 imageView가 축소됩니다. 더 이상 볼 수 없도록 조금 갈 수 있습니까?

https://github.com/HosniD/pinchzoom-iphone/blob/master/scroll/scroll/TestViewController.m

사람이 더 나은하는 방법에 대한 아이디어가 있습니까 :

여기 컨트롤러에 모습을 가질 수 있습니까?

+0

왜 handlePinchGesture가 있습니까? 이 제스처는 스크롤보기에서 이미 처리되었습니다. –

+0

무엇을 의미합니까? 그럼 내가 뭘해야 해? – Hosni

답변

0

원하는 상품이 Apple에 의해 작성되었습니다 PhotoScroller demo. 나는 그것을 사용했고 완벽하게 작동합니다.

특히 ImageScrollView 모듈을 확인하십시오. 확대/축소를 처리합니다.

여기 확대에 대해있는 UIScrollView의 헤더의 코드입니다 :

/* 
the following properties and methods are for zooming. as the user tracks with two fingers, we adjust the offset and the scale of the content. When the gesture ends, you should update the content 
as necessary. Note that the gesture can end and a finger could still be down. While the gesture is in progress, we do not send any tracking calls to the subview. 
the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale: in order for zooming to work and the max/min zoom scale must be different 
note that we are not scaling the actual scroll view but the 'content view' returned by the delegate. the delegate must return a subview, not the scroll view itself, from viewForZoomingInScrollview: 
*/ 

@property(nonatomic) float minimumZoomScale;  // default is 1.0 
@property(nonatomic) float maximumZoomScale;  // default is 1.0. must be > minimum zoom scale to enable zooming 
+0

실제로 그것은 멋진 방법이지만, 내가 한 것에 비해 조금 복잡해 보입니다. 또한 viewmImage에서 제스처 인식기를 설정하는 데 사용 된 지침이 표시되지 않습니다. 어떻게 생깁니 까? – Hosni

+0

UIScrollView의 maximumZoomScale 및 minimumZoomScale 속성을 설정하여이 작업을 수행합니다. 나는 내 대답을 편집했다. –

+0

그게 내 viewDidLoad ...에서 한거야 내 코드를 살펴 봤니? – Hosni

1

대답 사과 문서에서

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 

{ 

    return self.imageView; 

} 
- (void)viewDidLoad { 

    [super viewDidLoad]; 

    self.scrollView.minimumZoomScale=0.5; 

    self.scrollView.maximumZoomScale=6.0; 

    self.scrollView.contentSize=CGSizeMake(1280, 960); 

    self.scrollView.delegate=self; 

} 

Check my answer