Mar*_*eld 13 pdf xcode objective-c ios xcode6
当我尝试加载pdf并且不知道原因时,我得到了这个日志.
failed to find PDF header: `%PDF' not found.
Run Code Online (Sandbox Code Playgroud)
她的代码:
- (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.
}
Run Code Online (Sandbox Code Playgroud)
我使用Xcode 6 Beta 5和iOS 8 beta 5.
谢谢你的帮助.
小智 10
我同意,iOS 8 beta 5中似乎存在错误(或行为改变),这意味着您的代码不再有效(并且它是有效的.我有相同的功能,并且它在iOS 8 beta 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];
Run Code Online (Sandbox Code Playgroud)
现在这个代码不应该"按原样"使用,因为它是同步的.
我觉得Nithin的答案是有效的,但它没有回答iOS 8 beta 5中特别看到的问题.主要代码是相同的,会遇到相同的iOS错误.
这对我有用
NSURL *targetURL = [NSURL fileURLWithPath:pdfFilePath]; // <pdfFilePath> if full path of your pdf file
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL];
[self.webview loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
Run Code Online (Sandbox Code Playgroud)
2014年9月9日更新:iOS8 GM解决了我正在使用的应用程序的此问题。
2014年9月9日之前的响应Apple在iOS8 Beta 5发行说明中将其报告为已知错误。 https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-8.0/ https://devforums.apple.com/message/1017919#1017919
我们应该等待下一个版本,看看它是否已修复。
归档时间: |
|
查看次数: |
10693 次 |
最近记录: |