user717452
user717452

Reputation: 111

Zoom in on webview on appearing

I have a UIWebView that loads a PDF that is setup in landscape format and is very hard to read on the iPhone screen. My code is like this:

- (void)viewWillAppear:(BOOL)animated {
NSURL *url = [NSURL URLWithString:_entry.articleUrl];   
NSLog(@"%@",url);
[_webView loadRequest:[NSURLRequest requestWithURL:url]];
self.title = _entry.articleTitle;
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES];

}

What are some ways I could set it to be zoomed in more and possibly moved over to the right hand side of the top pdf page?

Upvotes: 3

Views: 1221

Answers (2)

AK_
AK_

Reputation: 2079

first make sure your UIWebView has scalesPageToFit property enabled

self.myWebView.scalesPageToFit = YES;

And then in your HTML add this tag inside the 'head' tag

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">

you can make maximum-scale=1.5 if that will make it appears better.

I am not sure about if it is a PDF file how to add these tags to it. Maybe you can add the tags and implement the PDF inside the html file.

Here is how to embeded a PDF file inside HTML

<embed src="filename.pdf" width="500" height="375">

Good luck!

Upvotes: 2

Paresh Navadiya
Paresh Navadiya

Reputation: 38259

In IOS version less than 5:

 UIScrollView *sv = [[_webView subviews] objectAtIndex:0];
 [sv setZoomScale:2.0 animated:NO];// increase scale factor to zoom more

In IOS 5:

  [_webView.scrollView setZoomScale:2.0 animated:NO];// increase scale factor to zoom more

You can use content offset to move to top right hand side

Upvotes: 0

Related Questions