12

I've googled a bit but could not find a simple Image Viewer class to use in my MonoTouch app.

I don't need to show image thumbnails neither a complete photo album (with multiple photos).

I just need an image viewer to show an UIImageView, allowing the common fullscreen/zoom operations.

Obviously such viewer could be implemented using a UIViewController subclass with UIGestureRecognizer, UIScrollView and UINavigationBar trickery, but I don't want to reinvent the wheel. Does anyone know about an open source component available ?

It would also be useful to host such component in the new Xamarin Component Store

Thanks

Eduardo Coelho
  • 1,953
  • 8
  • 34
  • 60

1 Answers1

11

Here it is.

Features:

  • Show both big images (larger than the screen) and small ones;
  • One tap to close view, two taps to zoom in/out. Pinch to zoom is also available;
  • Scrolling through available content. It's impossible to scroll image outside visible area. Thanks to UIScrollView's ContentSize property.

Suggestions for future:

  • I reduced code by removing UINavigationBar usage.
  • Also it's nice to add UIView's basic animation (fade in/out) when user opens/closes full screen image view.

Some relative info:

Any bug reports and suggestions are welcome!

Maxim Korobov
  • 2,574
  • 1
  • 26
  • 44
  • Yes, it would be really nice to add a fade transition for the open/close operations. Also I noticed that there's a delay to detect the 'single tap' on the picture (probable because of the timer you're using). Maybe it would be better to use a double-tap UIGestureRecognizer. – Eduardo Coelho Mar 11 '13 at 21:09
  • 2
    Done: Fade in/fade out transitions added; Better handling single and double taps (iOS method usage instead of timer); Red background for image was removed. It was used for debug purpose. – Maxim Korobov Mar 12 '13 at 06:37
  • Nice. There are a few enhancements that could still be done, such as zooming to the touch position (instead of just setting the zoom scale). – Eduardo Coelho Mar 12 '13 at 13:48
  • 2
    Done: Zoom to user specified point instead of center. – Maxim Korobov Mar 13 '13 at 07:29
  • This works great except the image does not rotate with the device. Is anyone else having a problem with it rotating? – Zach Green Feb 27 '14 at 21:57
  • Make a pull request! :) I switched from monotouch to native tools. – Maxim Korobov Feb 28 '14 at 03:48
  • This is absolutely awesome. Easy peasy – xleon Nov 02 '15 at 16:46
  • I'm very happy that code works 2+ years after it was done. – Maxim Korobov Nov 02 '15 at 17:23