In iPhone App I want add functionality to (imageview or webview or other control) zoom in/out an image with pinch gesture.
Asked
Active
Viewed 1,228 times
-1
-
you want to call other methods while zooming in or out? – Warif Akhand Rishi Jun 05 '12 at 06:30
-
@Prerak : Have you tried to google it ? – Devang Jun 05 '12 at 06:34
-
@devang no I want answer from SO – ios Jun 05 '12 at 06:40
-
@Prerak : Then use search feature of SO. – Devang Jun 05 '12 at 06:42
-
@ Warif Akhand Rishi : no I want to just display images with zoom in or or zoom out facility – ios Jun 05 '12 at 06:43
-
@Prerak: I have added the answer for the "facility" cum functionality of the zoom in and zoom out feature for the image view. – Parth Bhatt Jun 05 '12 at 06:44
-
2@Prerak : Check this link : http://stackoverflow.com/search?q=[iPhone]zoom+in%2Fout+using+Pinch&submit=search I have used SO search feature... – Devang Jun 05 '12 at 06:45
-
http://stackoverflow.com/questions/677006/how-to-zoom-image-in-iphone – Hector Jun 05 '12 at 06:46
-
refer this : http://stackoverflow.com/questions/500027/how-to-zoom-in-out-an-uiimage-object-when-user-pinches-screen – Hector Jun 05 '12 at 06:46
-
You might want to check this : http://www.iphonesdkarticles.com/2008/09/multi-touch-tutorial-3.html – JudeJitsu Jun 05 '12 at 06:29
2 Answers
3
You can use a UIScrollView
for that.
Add a UIImageView to the UIScrollView
and configure the UIScrollView for zooming via its propertys. Check the UIScrollview Class Reference - Zooming and Panning Section
Edit:
Good point by Mike: Check the PhotoScroller
sample code by Apple, too

Pfitz
- 7,336
- 4
- 38
- 51
-
1Also see the Apple "PhotoScroller" sample code which contains an ImageScrollView class which does this. It also handles some special cases like rotation that might interest you. – Mike Weller Jun 05 '12 at 07:15
0
Please refer to this code. I have used it in one of my apps so it works:
- (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer {
recognizer.view.transform = CGAffineTransformScale(recognizer.view.transform, recognizer.scale, recognizer.scale);
recognizer.scale = 1;
}
Also don't forget to add Pinch gesture recognizer to your imageView.
Hope this helps.

Parth Bhatt
- 19,381
- 28
- 133
- 216