我在尝试加载 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/