WKWebView causes my view controller to leak

后端 未结 6 1949
礼貌的吻别
礼貌的吻别 2020-12-12 11:52

My view controller displays a WKWebView. I installed a message handler, a cool Web Kit feature that allows my code to be notified from inside the web page:

o         


        
6条回答
  •  被撕碎了的回忆
    2020-12-12 12:54

    I've also noted that you also need to remove the message handler(s) during teardown, otherwise the handler(s) will still live on (even if everything else about the webview is deallocated):

    WKUserContentController *controller = 
    self.webView.configuration.userContentController;
    
    [controller removeScriptMessageHandlerForName:@"message"];
    

提交回复
热议问题