Unable to load PDF file on Webview with warning void SendDelegateMessage(NSInvocation *)

188 Views Asked by At

I am new in iOS and when I open PDF in UIWebView I am getting warning like this in console.

void SendDelegateMessage(NSInvocation *): delegate (webView:didFirstLayoutInFrame:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode

2017-07-11 16:55:38.304119+0530 appname[1334:540218] libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see <rdar://problem/11744455>)

Here is the code below to open a PDF file on Webview from NSBundle

    visionweb.delegate=self;

NSURL *targetURL = [[NSBundle mainBundle] URLForResource:@"a0" withExtension:@"pdf"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];

[visionweb loadRequest:request];

[self.view addSubview:visionweb];

Here visionweb is my UIWebview object.

I tried to open other PDF file using same code and was able to open them. But When I try to open this particular file, it shows the above message on console.

Both the delegate methods

  1. - (void)webViewDidStartLoad:(UIWebView *)webView; and
  2. - (void)webViewDidFinishLoad:(UIWebView *)webView;

gets called when I try to open another PDF file.

But when I try to open that particular PDf file , it only calls the first delegate method, that is only -(void)webViewDidStartLoad:(UIWebView *)webView; gets called, and not the other one.

I am not able to understand the problem behind it. I have searched it on internet and found so many people facing this same issue, but their solution did not helped me. I am using Xcode 6.2.

1

There are 1 best solutions below

5
On

Here is a solution. I have used below code and it's working for me.

termsWebView.delegate = self;
NSString *path = [[NSBundle mainBundle] 
pathForResource:@"Terms_of_Use_20170523" ofType:@"docx"];

NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[termsWebView loadRequest:request];