【问题标题】:swift void SendDelegateMessage.. webView:decidePolicyForNavigationActionfailed to return after waiting 10 seconds... kCFRunLoopDefaultModeswift void SendDelegateMessage.. webView:decidePolicyForNavigationAction 等待 10 秒后返回失败... kCFRunLoopDefaultMode
【发布时间】:2015-09-18 22:24:15
【问题描述】:

我创建了与 ios 7 和 ios 8 兼容的应用程序,但 ios 7 上的 UIWebview 从未调用过,我得到了

void SendDelegateMessage(NSInvocation *): 委托 (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) 等待 10 秒后未能返回。主运行循环模式: kCFRunLoopDefaultMode

我在互联网上搜索但没有解决方案 4天尝试,没有运气..

    class AWTncViewController: UIViewController, UIWebViewDelegate{
 @IBOutlet weak var wv: UIWebView!

    deinit {
        NSNotificationCenter.defaultCenter().removeObserver(self)
        wv.delegate = nil

    }

    override func viewDidLoad() {
        super.viewDidLoad()


        super.viewDidLoad()
        self.wv.delegate = self;
        let myHTMLString:String! = "<h1>Hello word!</h1>"
        self.wv.loadHTMLString(myHTMLString, baseURL: nil)
     }
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
       /* Test 2 still not load
         let myHTMLString:String! = "<h1>Hello word!</h1>"
        self.wv.loadHTMLString(myHTMLString, baseURL: nil)
       */
    }



    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
        //this never called
        println("shouldStartLoadWithRequest execute") 
        return true
    }

    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool
    {
        //this never called
    println("shouldStartLoadWithRequest execute")
         return true

    }

    func webViewDidStartLoad(webView: UIWebView)
    {
       //this never called
        println("Start load")
    }
    func webViewDidFinishLoad(webView: UIWebView)
    {
        //this never called
        println("FinishLoad")
    }
    func webView(webView: UIWebView, didFailLoadWithError error: NSError)
    {
        //this never called
        println("didFailLoadWithError: \(error.description)")
    }





    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }



}

我读到了这个:iOS 7 UIWebView not rendering

但我没有使用 Crittercism

【问题讨论】:

    标签: ios swift uiwebview xcode6


    【解决方案1】:

    我也遇到过这个问题。似乎问题是在链接某些第 3 方库时引起的,但我什至不确定在我的情况下到底是哪一个库负责。

    为我解决的问题是我发现 here on Apple's Dev Forum 提早实例化 UIWebView 的建议。

    - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // In a severe case of WTF: some 3rd party libs (exact culprit unknown) can cause webviews to stop
        // showing anything on iOS 7, and instead have console warnings every 10 seconds that look like:
        // void SendDelegateMessage(NSInvocation *): delegate (webView:decidePolicyForNavigationAction:request:frame:decisionListener:) failed to return after waiting 10 seconds. main run loop mode: kCFRunLoopDefaultMode
        // Just instantiating an UIWebView before any of the 3rd party libs kick in is enough to fix it.
        // Don't know why, but it works.
        if (SYSTEM_VERSION_LESS_THAN(@"8.0")) {
            UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 320)];
            webView.delegate = nil; // Do something with webView to silence warning
        }
        return YES;
    }
    

    【讨论】:

      猜你喜欢
      • 2011-06-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-02
      • 2018-01-02
      相关资源
      最近更新 更多