How can I load a local HTML file into the UIWebView?

前端 未结 7 976
有刺的猬
有刺的猬 2020-12-09 03:17

How can we load our own html file into the UIWebView?

7条回答
  •  生来不讨喜
    2020-12-09 03:21

    Swift

        guard let path = NSBundle.mainBundle().pathForResource("index", ofType: "html") else {
            return
        }
    
        let url = NSURL(fileURLWithPath: path)
        self.webview.loadRequest(NSURLRequest(URL:url))
    

提交回复
热议问题