【问题标题】:Unable to load PDF file on Webview with warning void SendDelegateMessage(NSInvocation *)无法在 Webview 上加载 PDF 文件并带有警告 void SendDelegateMessage(NSInvocation *)
【发布时间】:2017-12-27 10:00:39
【问题描述】:

我是 iOS 新手,当我在 UIWebView 打开 PDF 时,我在控制台中收到这样的警告。

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>)

下面是从 NSBundle 在 Webview 上打开 PDF 文件的代码

    visionweb.delegate=self;

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

[visionweb loadRequest:request];

[self.view addSubview:visionweb];

这里 visionweb 是我的 UIWebview 对象。

我尝试使用相同的代码打开其他 PDF 文件并且能够打开它们。但是当我尝试打开这个特定文件时,它会在控制台上显示上述消息。

两种委托方法

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

当我尝试打开另一个 PDF 文件时被调用。

但是当我尝试打开那个特定的 PDf 文件时,它只调用了第一个委托方法,即只有 -(void)webViewDidStartLoad:(UIWebView *)webView; 被调用,而不是另一个。

我无法理解其背后的问题。我在互联网上搜索过,发现很多人面临同样的问题,但他们的解决方案对我没有帮助。我正在使用 Xcode 6.2。

【问题讨论】:

    标签: ios pdf uiwebview uiwebviewdelegate webviewdidfinishload


    【解决方案1】:

    这里有一个解决方案。我使用了下面的代码,它对我有用。

    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];
    

    【讨论】:

    • @Jignesh-是的。我也使用了相同的代码及其对其他文件的工作,但是当我尝试打开这个文件 - >“a0.pdf”时,它在控制台中给了我上面的警告。有没有其他方法可以在 webview 上加载 pdf,或者其他方法来检测该 pdf 文件的内容是否正确。请帮帮我。
    • NSData *WebData=[NSData dataWithContentsOfURL:soundURL]; [_webView loadData:WebData MIMEType:@"application/pdf" textEncodingName:@"UTF-8" baseURL:nil];试试这个!
    • 不帮我。
    • @Jignesh-你能帮我解决我关于本地化的其他问题吗?我真的很感激。请帮帮我。
    • 是的,您确定在此处发布了该问题吗?
    猜你喜欢
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-25
    相关资源
    最近更新 更多