swift// 首先呢要把这个HTML文件加入到项目之中class WebViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() //检查 BullsEye.html是否存在 if let htmlFile = NSBundle.mainBundle().pathForResource("BullsEye", ofType: "html"){ let htmlData = NSData(contentsOfFile: htmlFile) let baseURL = NSURL.fileURLWithPath(NSBundle.mainBundle().bundlePath) web.loadData(htmlData, MIMEType: "text/html", textEncodingName: "UTF-8", baseURL: baseURL) } } //UIWebView @IBOutlet weak var web: UIWebView!}
OK,接下来运行APP就可以看到这个静态的HTML页面了。
Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务