janagowtham janagowtham - 1 month ago 24
Objective-C Question

pinch zooming in image viewer

I have an

UIImageView
. I need pinch zoom.

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 90, 320, 38)];
[imageView setImage:[UIImage imageNamed:@"accesspanel.png"]];
[self.view addSubview: imageView];

Answer

You can add the imageview inside a scrollview and can use Scrollview delegate for the this purpose

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

    return self.imageView;

}
- (void)viewDidLoad {

    [super viewDidLoad];

    self.scrollView.minimumZoomScale=0.5;

    self.scrollView.maximumZoomScale=6.0;

    self.scrollView.contentSize=CGSizeMake(1280, 960);

    self.scrollView.delegate=self;

}