Hi I am new i want to develop a application that we zoom in and zoom out image but i am not understand how to do this. any one help me with code and other
-
Are you using a UIScrollView? – kennytm May 06 '10 at 10:02
-
These questions are very close to yours: http://stackoverflow.com/questions/1107573/how-to-do-pinch-gestures-on-the-iphone , http://stackoverflow.com/questions/2517134/iphone-smooth-move-and-pinch-of-uiimageview , http://stackoverflow.com/questions/2135744/iphone-uiimageview-pinch-zoom – Brad Larson May 06 '10 at 12:29
3 Answers
For iPhone OS 3.2 or higher, use the bundled gesture recogniser UIPinchGestureRecognizer
.

- 181,030
- 38
- 327
- 365
In my opinion the easiest way would be to add an UIScrollView
to your viewcontroller which will be the scrollviews delegate.
Then you'll implement the viewForZoomingInScrollView
UIScrollViewDelegate
method where you'll return the UIImageview
that has to be zoomed/pinched.
You would also need to set the maximumZoomScale
and minimumZoomScale
properties of the UIScrollView.
UIScrollView documentation UIScrollViewDelegate documentation

- 4,354
- 1
- 26
- 28
A scroll view also handles zooming and panning of content. As the user makes a pinch-in or pinch-out gesture, the scroll view adjusts the offset and the scale of the content. When the gesture ends, the object managing the content view should should update subviews of the content as necessary. (Note that the gesture can end and a finger could still be down.) While the gesture is in progress, the scroll view does not send any tracking calls to the subview.
The UIScrollView class can have a delegate that must adopt the UIScrollViewDelegate protocol. For zooming and panning to work, the delegate must implement both viewForZoomingInScrollView: and scrollViewDidEndZooming:withView:atScale:; in addition, the maximum (maximumZoomScale) and minimum ( minimumZoomScale) zoom scale must be different.

- 3,369
- 2
- 30
- 48