Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Load HTML string crash in Swift #24

Closed
hisoka0917 opened this issue Jan 19, 2018 · 1 comment
Closed

Load HTML string crash in Swift #24

hisoka0917 opened this issue Jan 19, 2018 · 1 comment

Comments

@hisoka0917
Copy link

hisoka0917 commented Jan 19, 2018

我在swift项目里使用dsBridge,用cocoapods集成。然后添加DWebview

var webView = DWebview()

override func viewDidLoad() {
        super.viewDidLoad()
        self.webView.frame = self.view.bounds
        self.view.addSubview(self.webView)
        let jsApi = JsApiHandler()
        self.webView.javascriptInterfaceObject = jsApi
    }

    func loadHTML(_ html: String, baseURL: URL?) {
        self.webView.loadHTMLString(html, baseURL: baseURL ?? URL(string: "*")!)
    }

业务需要后端返回的是一个HTML字符串,然后用WebView显示这个页面。

因为该库用OC写的,而原生UIWebView的loadHTMLString方法的baseURL参数是可选参数,DWebView暴露的接口参数没有支持nullable,所以这里就必须填写一个非nil的baseURL,这样要么crash,要么黑屏。

希望接口能支持Swift友好的nullable协议。

补充:单独使用DUIWebView或者DWKWebView使用loadHTMLString方法baseURL为nil运行正常。

wendux pushed a commit that referenced this issue Jan 23, 2018
@wendux
Copy link
Owner

wendux commented Jan 23, 2018

fixed! please update version to 2.0.5

@wendux wendux closed this as completed Jan 23, 2018
wendux pushed a commit that referenced this issue Feb 2, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants