开发者

UIWebView - main loop mode kCFRunLoopDefaultMode

开发者 https://www.devze.com 2023-03-22 14:47 出处:网络
I\'m loading a UIWebView by using the method loadData. With some specific data which is quite long, I\'m getting the following error:

I'm loading a UIWebView by using the method loadData. With some specific data which is quite long, I'm getting the following error:

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

It occurs after webViewDidFin开发者_开发百科ishLoad. Any idea how can I find out what I'm doing wrong? I'm not using any javascript.


the issue is that a web view does not want to get 'stuck' calling a delegate that may or may not return

so it throws that error after 30s saying that it is the DELEGATES fault that things dont continue

what you can do is :

- (void)webview:(id)wv didFinishLoadForFrame:(id)f {
    [self performSelector:@selector(delayedDidFinish:) withObject:f afterDelay:0.0];
}

- (void)delayedDidFinish:(id)f {
    ...
}

That will let the delegate return and then run stuff when the runloop comes around the next time

====

with GCD, just use dispatch_async - more modern than performSelector:

0

精彩评论

暂无评论...
验证码 换一张
取 消