【发布时间】:2012-11-19 23:54:37
【问题描述】:
我的应用程序的“支持文件”文件夹包含一个名为 test.pdf 的文档。
尝试在ViewDidLoad 中使用以下代码查看 pdf 文件会显示一个空的 UIWebView:
NSString *testPath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"pdf"];
NSURL *testURL = [NSURL URLWithString:testPath];
NSURLRequest *testRequest = [NSURLRequest requestWithURL:testURL];
UIWebView *documentWebView;
documentWebView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 24, 300, 400)];
[documentWebView loadRequest:testRequest];
[self.view addSubview:documentWebView];
谁能告诉我为什么 PDF 没有显示在 Web 视图中?谢谢。
【问题讨论】:
-
该 pdf 文件是否已添加到您的 xcode 中?
-
是的,在“支持文件”文件夹中。
-
尝试删除并重新添加。还要检查 Target -> “Build Phases” -> “copy bundle Resources” 并确保它存在
-
感谢您的建议。我尝试删除并再次添加,文档在 Build Phases 中列出,但没有任何乐趣。
-
这能解决您的问题还是您仍然面临它?