ios - 找不到 PDF 标题 : `%PDF' not found

标签 ios objective-c xcode pdf xcode6

我在尝试加载 pdf 时收到此日志,但不知道为什么。

failed to find PDF header: `%PDF' not found.

她是我的代码:

- (void)viewDidLoad
{


    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://webdesign-schoenefeld.de/es-app/heute.pdf"]]];
    NSLog(@"---------------pdfloading....,------------------------");
    [webview addSubview:activityind];
    timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0)
                                             target:self
                                           selector:@selector(loading)
                                           userInfo:nil
                                            repeats:YES];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

}

我使用 Xcode 6 Beta 5 和 iOS 8 beta 5。

感谢您的帮助。

最佳答案

我同意,在 iOS 8 beta 5 中似乎有一个错误(或行为改变),这意味着您的代码不再有效(并且它是有效的。我有相同的并且它在 iOS 8 之前运行良好测试版 4)。

我认为类型检测存在问题,因为如果我执行以下操作,它会起作用:

NSLog(@"About to request PDF document loading...");
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:urlStr]];
[self.webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];

现在这段代码不应该“按原样”使用,因为它是同步的。

我觉得 Nithin 的回答是有效的,但它没有回答在 iOS 8 beta 5 中特别出现的问题。主要代码是相同的,并且会遇到相同的 iOS 错误。

关于ios - 找不到 PDF 标题 : `%PDF' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25158552/

相关文章:

objective-c - 在 Mac 应用程序中提升到管理员权限

swift - xcode 8 swift 3 中的多点连接框架中对成员 'session(_:peer:didChange)' 错误的不明确引用

ios - Swift 4 UIButton 附加在 View 上

ios - FBSDKLoginManager logInWithReadPermissions?

ios - AppAuth - 外部浏览器窗口打不开?

objective-c - iOS 5 : Make NSString Category include NSCFConstantString?

ios - 如何创建一个按钮,但使其具有两个功能?

ios - 如何使用 swift 在 firestore 文档的字段中创建空值?

ios - 'NSInvalidArgumentException',原因 : 'Unable to parse constraint format

ios - 不使用日历或提醒应用程序的 EventKit