I have an UIImageView in a UITableviewCell. When it is tapped, the UIImageView should animated to be displayed fullscreen. When the image is tapped when it is fullscreen it should shrink back to the original position.
How can this be achieved?
I have an UIImageView in a UITableviewCell. When it is tapped, the UIImageView should animated to be displayed fullscreen. When the image is tapped when it is fullscreen it should shrink back to the original position.
How can this be achieved?
One possible implementation would be to use a modal view controller with UIModalPresentationFullScreen presentation style.
Add a gesture recognizer to the view controller.
Add the gesture Recognizer to your header file
In your viewDidLoad add this:
Add the following delegatemethod:
Now you just need to implement your imgToFullScreen method. Make sure you work with the isFullScreen Bool (fullscreen if it is false and back to old size if it's true)
The imgToFullScreen method depends on how you want to make the image become fullscreen. One way would be: (this is untested but should work)
The code from @AzzUrr1, small error corrections (brackets) and tapper implemented slightly different.
Worked for me. Now it would be great to have this implemented with a scrollView, that the user can zoom in/out if the picture is bigger.. Any suggestion?
ViewController.h
ViewController.m
I ended up using MHFacebookImageViewer. Integration is easy, no subclassing
UIImageView
, and it also has image zooming and flick dismiss.Although it requires
AFNetworking
(for loading larger image from URL), you can comment out some code (about 10 lines) to remove this dependency. I can post my AFNetworking-free version if someone needs it. Let me know :)Just finished a version in swift, just download and add into your project:
GSSimpleImageView.swift
And usage: