#ios #objective-c #pdf #wkwebview
#iOS #objective-c #PDF #wkwebview
Вопрос:
Я использую удаленный URL-адрес для отображения PDF-файла в webview. Он отлично работает с UIWebView в ios 12. Но в iOS 13.0 отображается пустая страница. Также я попробовал WKWebView. В iOS 12 и 13 отображается пустая страница. Мой URL-адрес pdf не имеет расширения .pdf
Это выглядит как https://xxx.xxx.xxx.xxx/MYTASKS4/fileupload.ashx?docno=CTBMJV/000001/19amp;doctype=JournalVoucheramp;atch=0amp;empcode=00797
Вот мой код
NSString *body = [NSString stringWithFormat:@"docno=%@amp;doctype=%@amp;atch=%@amp;fname=%@amp;empcode=%@", gStrTranId,gStrTranNo,gStrAttachmentType,gStrFileName,gStrUserCode];
body = [body stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
NSURL *aUrl = [NSURL URLWithString:[NSString stringWithFormat:@"https://xxx.xxx.xxx.xxx/MYTASKS4/filedownload.ashx?%@",body]];
NSMutableURLRequest *request = [NSMutableURLRequest new];
NSDictionary *customHeaders = @{@"Authorization": [NSString stringWithFormat:@"Bearer %@",[SESSION getKeyValue]] , @"auth_key": [NSString stringWithFormat:@"Bearer %@",[SESSION getAuthorizeCode]], @"Content-Type": @"text/xml; charset=utf-8" };
// set the new headers
for(NSString *key in [customHeaders allKeys]){
[request addValue:[customHeaders objectForKey:key] forHTTPHeaderField:key];
}
[request setHTTPMethod:@"POST"];
[request setURL:aUrl];
self.myWebView1.navigationDelegate = self;
self.myWebView1.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[self.myWebView1 loadRequest:request];
Комментарии:
1. я также сталкиваюсь с той же проблемой, если у вас есть решение, пожалуйста, отправьте ответ.