WKWebView showing blank on device, working on simulator

走远了吗. 提交于 2019-12-01 01:14:42

i had some problem but i solved problem with configuration options. here is my my code.

    var a = dic["adi"]?.asString()
    var path = NSBundle.mainBundle().pathForResource(a, ofType: "htm" )
    var url = NSURL(fileURLWithPath:path!)
    var request = NSURLRequest(URL:url!)

    var theConfiguration = WKWebViewConfiguration()

    theWebView = WKWebView(frame:self.view.frame, configuration: theConfiguration)

    var error:NSError?
    let text2 = String(contentsOfFile: path!, encoding:NSUTF8StringEncoding, error: &error)

    if let theError = error
    {
        print("\(theError.localizedDescription)")
    }

    theWebView!.loadHTMLString(text2!, baseURL: nil)
    self.view.addSubview(theWebView!)

hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!