xcode - DiskImageCache : Could not resolve the absolute path of the old directory. 未能找到 PDF header : `%PDF' 未找到

标签 xcode pdf

在我的一个 View 中,我只想在 UIWebView 中显示一个 pdf 文件。

我的头文件代码:

    #import <UIKit/UIKit.h>

@interface FCOMViewController : UIViewController

{IBOutlet UIWebView *fcomWebView;}

//flag to denote if this is first time the app is run

@property (nonatomic) BOOL firstRun;

@end

这里是实现文件中的方法:
- (void)viewDidLoad {

    //Show the procedures PDF

NSString *path = [[NSBundle mainBundle] pathForResource:@"b777normalprocedures" ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[fcomWebView loadRequest:request];
[fcomWebView setScalesPageToFit:YES];

该应用程序启动良好,没有崩溃或任何事情。引用导出已设置,但不显示 PDF。控制台说:

DiskImageCache: Could not resolve the absolute path of the old directory. failed to find PDF header: `%PDF' not found.



pdf 在项目目录中,我已经仔细检查过它是否正确写入。

我能在这里做什么?任何帮助,将不胜感激。

最佳答案

如果你的目标是 iOS 8.0,试试这个:

 NSString *path = [[NSBundle mainBundle] pathForResource:@"b777normalprocedures" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL];
[_webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];

关于xcode - DiskImageCache : Could not resolve the absolute path of the old directory. 未能找到 PDF header : `%PDF' 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25412424/

相关文章:

objective-c - 如何在 Swift/XCode 中的 Controller 之间共享(MVC)模型?

安装xcode 6 beta后Xcode 4.6.3崩溃

ios - Xcode 7.1 在归档 swift ios 应用程序时挂起

php - 使用 FPDM 填充 PDF 表单

java - PDFBox 是否支持专色和分色?

xcode - Cocoa - 以编程方式转到前台/后台

java - 使用 iText 5,如何将 PDF 文件另存为线性化 PDF

java - 使用 IText 在 PDF 中嵌入非嵌入字体

python - 如何使用 PIL (pillow) 以 PDF 格式保存图像列表?

ios - UIAlertView 使应用程序崩溃