3
- (void) viewWillAppear:(BOOL)animated
{

 [super viewWillAppear:animated];

    NSString *path = [[NSBundle mainBundle] pathForResource:@"About" ofType: @"pdf"];

    NSLog(@"%@", path);

    NSURL *targetURL = [NSURL fileURLWithPath:path];

    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];

    [_webView loadRequest:request];

}
4

3 回答 3

0

只需使用以下代码在 Web 视图中打开 PDF

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"About" ofType:@"pdf"]; 
[self.webVctr loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

并检查 PDF 是否存在?

这认为可能对你有帮助

快乐码字。。

于 2012-07-16T09:46:48.603 回答
0

试试这个:

在里面

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

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

[self.view addSubview:webView];
[webView release];
于 2012-07-16T09:47:12.813 回答
0

这是与通过 Web 视图加载 pdf 无关的其他问题。我交叉检查并找到了崩溃的实际原因。不管怎样,谢谢大家的帮助

于 2012-07-16T12:25:18.240 回答