3

我有一个加载 PDF 文件的 WebView:

[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL 
fileURLWithPath:[[NSBundle mainBundle] pathForResource:fileName
ofType:@"pdf"]isDirectory:NO]]];

它在 iPhone OS 2.x 上运行良好,但在 iPhone 3.0 上,当我点击 PDF 进行滚动时,出现此错误,并且应用程序崩溃:

-[NSCFDictionary _absoluteLinkURL]:无法识别的选择器发送到实例 0x1c0230 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[NSCFDictionary _absoluteLinkURL]:无法识别的选择器发送到实例 0x1c0230”

4

2 回答 2

1

尝试这个:

NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
于 2010-03-27T01:38:20.683 回答
0

我会尝试把它放在一个单独的行:

NSString *path = [[NSBundle mainBundle] pathForResource:fileName
ofType:@"pdf"]isDirectory:NO];

然后看看什么

NSLog(@"path: %@",path);

输出。

只是为了确保你得到你所期望的,我不确定 2.x 和 3.0 之间关于这些调用的细微差别,这只是我帮助你解决问题的 2 美分。

于 2010-03-15T14:58:46.873 回答