内容简介:首先把静态页面写好,建议不要在xcode里写,着实难用,可以用sublime/vscode之类的编辑器来写html,css,js,写好之后,打开xcode,把静态页面文件夹直接拖动到项目里,弹出窗口上选择我这的目录结构是这样的
首先把静态页面写好,建议不要在xcode里写,着实难用,可以用sublime/vscode之类的编辑器来写html,css,js,写好之后,打开xcode,把静态页面文件夹直接拖动到项目里,弹出窗口上选择 create group ,如下图
我这的目录结构是这样的
html引入css,js写法如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,user-scalable=no" /> <link rel="stylesheet" href="app.css"> <script src="underscore.min.js"></script> </head> <body> </body>
下面是swift里通过代码加载html
// 将页面内容转成string let TOPICDETAILHTML = try! String(contentsOfFile: Bundle.main.path(forResource: "topic_detail", ofType: "html")!, encoding: String.Encoding.utf8) // 通过webview加载 webView.loadHTMLString(TOPICDETAILHTML, baseURL: Bundle.main.resourceURL)
然后运行项目,页面就加载进来了,然后就可以通过swift与webview之间交互来开发了,详见博客 https://tomoya92.github.io/2018/07/05/swift-webview-javascript/
原文链接:
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
500 Lines or Less
Amy Brown、Michael DiBernardo / 2016-6-28 / USD 35.00
This book provides you with the chance to study how 26 experienced programmers think when they are building something new. The programs you will read about in this book were all written from scratch t......一起来看看 《500 Lines or Less》 这本书的介绍吧!