在出现时放大webview

时间:2012-06-12 13:59:12

标签: iphone ios xcode uiwebview zoom

我有一个UIWebView,可以加载以横向格式设置的PDF,并且很难在iPhone屏幕上阅读。我的代码是这样的:

- (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];

}

我有哪些方法可以将其设置为放大更多并可能移到顶部pdf页面的右侧?

2 个答案:

答案 0 :(得分:2)

首先确保您的UIWebView已启用scalesPageToFit属性

self.myWebView.scalesPageToFit = YES;

然后在您的HTML中将此标记添加到“head”标记

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

你可以 maximum-scale = 1.5 ,如果这样可以让它看起来更好。

我不确定它是否是PDF文件如何添加这些标签。也许你可以添加标签并在html文件中实现PDF。

以下是如何在HTML中嵌入PDF文件

<embed src="filename.pdf" width="500" height="375">
祝你好运!

答案 1 :(得分:0)

IOS版本低于5:

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

在IOS 5中:

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

您可以使用内容偏移移至右上角

相关问题