ios 等待 10 秒后未能返回,尽管返回了 BOOL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15280176/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
failed to return after waiting 10 seconds although getting a BOOL back
提问by Segev
I'm trying to show a fully loaded webview. I don't want the user to see the webview in the loading process. I'm handling a few webviews at a time and using webViewDidFinishLoad
makes it a lot more complex for me so I'm trying to do something like this:
我正在尝试显示一个完全加载的 web 视图。我不希望用户在加载过程中看到 webview。我一次处理几个网络视图,使用webViewDidFinishLoad
它对我来说变得更加复杂,所以我正在尝试做这样的事情:
while(_lastWebView.isLoading)
{
_lastWebView.hidden=YES;
}
_lastWebView.hidden=NO;
But I get this msg: void SendDelegateMessage(NSInvocation *): delegate () failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
但是我得到这个消息:void SendDelegateMessage(NSInvocation *): delegate () 等待 10 秒后未能返回。主运行循环模式:kCFRunLoopDefaultMode
I don't understand why is entering a loop because isLoading
returns 0 when the loading is finished.
我不明白为什么要进入循环,因为isLoading
加载完成后返回 0。
回答by Aaron Brager
Don't block your UI with that loop. It will stop the user from doing anything else on the main thread.
不要用那个循环阻塞你的 UI。它将阻止用户在主线程上做任何其他事情。
Instead, count the number of requests your webView makes, and make it visible when it's done loading.