I have an UIImage
captured from the camera with UIImagePickerController
.
Now after the user clicks on it, I\'d like it to show full screen and
i have create this effect for one of my app, dont forget to set delegate of your scrollview.
code for .h file
#import
@interface ImageViewerController : UIViewController
// The scroll view used for zooming.
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
// The image view that displays the image.
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
// The image that will be shown.
@property (strong, nonatomic) NSString *imageUrlString;
@end
code for .m
#import "ImageViewerController.h"
@interface HNImageViewerController ()
- (IBAction)handleSingleTap:(UIButton*)tapGestureRecognizer;
@end
@implementation ImageViewerController
- (void)viewDidLoad {
[super viewDidLoad];
[self.imageView setImage:[UIImage imageNamed:@"placeholder-image"]];
self.scrollView.delegate=self;
}
- (BOOL)prefersStatusBarHidden {
return YES;
}
#pragma mark - UIScrollViewDelegate methods
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return self.imageView;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (self.scrollView.zoomScale == self.scrollView.minimumZoomScale) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
#pragma mark - Private methods
- (IBAction)handleSingleTap:(UIButton *)tapGestureRecognizer {
[self dismissViewControllerAnimated:YES completion:nil];
}