在uiwebview中显示全屏pdf

时间:2011-03-24 10:45:49

标签: iphone objective-c xcode ipad uiwebview

我正在尝试在uiwebview中加载pdf,但pdf会在写手侧显示空格

如何让全屏显示

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

1 个答案:

答案 0 :(得分:5)

在webview上设置属性scalesPagesToFit,你应该没问题。