2011-03-24 73 views
1

我试图在UIWebView中加载PDF,但PDF格式全屏PDF可以在写右手边显示在UIWebView的

如何让全屏幕显示

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height)]; 

    //webView.contentMode = UIViewContentModeScaleAspectFit; 

    NSString *path = [[NSBundle mainBundle] pathForResource:@" manual" ofType:@"pdf"]; 
    NSURL *targetURL = [NSURL fileURLWithPath:path]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; 


    CGRect frame = webView.frame; 
    // you may need to modify the 5 and 10 below to match the size of the PDF border 
    frame.origin.x = frame.origin.x - 5; 
    frame.origin.y = frame.origin.y - 5; 
    frame.size.width = frame.size.width + 100; 
    frame.size.height = frame.size.height + 100; 


    webView.frame = frame; 

    [webView loadRequest:request]; 

    [self.view addSubview:webView]; 
    [webView release]; 
+0

你可以把你得到的一个截图 – 2011-03-24 10:50:27

回答

6

在以空格显示webview设置属性scalesPagesToFit,你应该没问题。

+0

这真棒! – 2011-10-10 15:34:59

+0

Mh,在iOS7中不适用于我: - / – Chris 2014-05-15 17:39:37