且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用swift将本地html加载到UIWebView中

更新时间:2023-10-31 12:08:34

要检索应用程序资源的URL,您应该使用 URLForResource NSBundle 类的方法。

To retrieve URLs for application resources, you should use URLForResource method of NSBundle class.

Swift 2

let url = NSBundle.mainBundle().URLForResource("privacy", withExtension:"html") 

Swift 3

let url = Bundle.main.url(forResource: "privacy", withExtension: "html")