我有一个功能,可以在全屏模式下在 WebView 中打开 PDF 文件。
如何添加“完成”按钮,可以关闭 WebView?
- (IBAction)openPDF:(id)sender {
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:@"pdf" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
CGRect frame = webView.frame;
webView.scalesPageToFit = YES;
webView.frame = frame;
[webView loadRequest:request];
[self.view addSubview:webView];
}