6

I am trying to workout how to implement a UIImage that has pinch/double tap to zoom. Is this possible with a standard UIImageView?

Looking at other questions at documentation it has to be completed with a UIScrollView?

Source: https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/ZoomingByTouch/ZoomingByTouch.html

The issue I see is that the above link suggests using initWithImage on the scrollView, but that is not available?

I am looking to implement an Image that is full screen (no larger), if the image is larger it should scale Aspect to Fit into the full screen. The user can then double tap or Pinch to zoom into the image. What is the correct approach for this?

StuartM
  • 6,743
  • 18
  • 84
  • 160
  • If you read previous paragraph in the guide you will see that `initWithImage` is from "TapToZoom example in the ScrollViewSuite sample code project, in the TapDetectingImageView class, which is a subclass of UIImageView." – yurish Dec 27 '13 at 19:13
  • I could not find that sample code available, can you? – StuartM Dec 27 '13 at 19:17
  • 2
    Intresting... I downloaded the code not long ago from the Apple site and now cannot find too. Looks like they removed it. You can try to look here at github https://github.com/darcyliu/SampleCode/tree/master/ScrollViewSuite – yurish Dec 27 '13 at 19:30
  • Great thanks, thought I was going mad – StuartM Dec 27 '13 at 19:32
  • http://stackoverflow.com/questions/9008975/how-to-tap-to-zoom-and-double-tap-to-zoom-out-with-uiscrollview/9009554#9009554 – GWed Feb 17 '14 at 16:13

1 Answers1

12

Never try to zoom an image itself - it consumes just too much time. Instead, as you've mentioned, zoom the view. It can be made with UIScrollView using almost default parameters.

Here is how: How to zoom in/out an UIImage object when user pinches screen?

Community
  • 1
  • 1
dreamzor
  • 5,795
  • 4
  • 41
  • 61