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 の読み込みに関連しない他の問題でした。クロスチェックして、クラッシュの実際の原因を見つけました。とにかく助けてくれてありがとう

于 2012-07-16T12:25:18.240 に答える
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 に答える