wkewbview警报对话框未显示在ipad上

问题描述

我使用WKWebView。

“警告”对话框在iPhone上正常工作,但在iPad上不可见。我该如何解决?

func webView(_ webView: WKWebView,runJavaScriptAlertPanelWithMessage message: String,initiatedByFrame frame: WKFrameInfo,completionHandler: @escaping () -> Void) {
        
    let alertController = UIAlertController(title: nil,message: message,preferredStyle: .actionSheet)
    
    alertController.addAction(UIAlertAction(title: "Ok",style: .default,handler: { (action) in
        completionHandler()
    }))
    
    
    if UIDevice.current.userInterfaceIdiom == .pad {

        if let popoverPresentationController = alertController.popoverPresentationController {
            
            popoverPresentationController.sourceView = self.view
            popoverPresentationController.sourceRect = CGRect(x: self.view.bounds.midX,y: self.view.bounds.midY,width: 0,height: 0)
            
            popoverPresentationController.permittedArrowDirections = []

        }

    } else {
        
        self.present(alertController,animated: true,completion: nil)
        
    }

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)