Reputation: 891
I'm trying to add a UIImageView in the scrollview of UIWebView, thereby i hope i can enable pinch zoom and pan gestures which are properties of UIWebView.
[webView.scrollView addSubview:imageView];
webView.multipleTouchEnabled = YES;
webView.scalesPageToFit = YES;
[self.view addSubview:webView];
But i can't do those Gestures.
Will this work? or should I use the default UIGestureRecognizer?
Upvotes: 1
Views: 1449
Reputation: 891
Instead of loading the image in an imageView and then adding the imageView to the webView, you can simply load the image directly on the webView, thereby applying all zoom,pinch and pan properties of the webView to the image.
NSString *path = [[NSBundle mainBundle] pathForResource:@"imageName" ofType:@"jpg"];
[webView loadHTMLString:[NSString stringWithFormat:@"<html><body><img src=\"file://%@\"></body></html>",path] baseURL:nil];
Upvotes: 1
Reputation: 1476
If you want zoom&pan features then just use UIScrollView with UIImageView set as contentView (Adding UIImageViews to UIScrollView)
Upvotes: 0