美文网首页
Swift - WebView 加载 Html [String

Swift - WebView 加载 Html [String

作者: 桑乔朋友 | 来源:发表于2016-09-27 11:11 被阅读0次

    var htmlString = ""

    let path = NSBundle.mainBundle().pathForResource("lineHead", ofType:"html")

    do {

    let contents = try NSString(contentsOfFile: path!, usedEncoding: nil) as String

    htmlString = contents

    } catch {

    // contents could not be loaded

    }

    let pathJS = NSBundle.mainBundle().pathForResource("jquery", ofType:"js")

    let urlJS = NSURL.fileURLWithPath(pathJS!);

    print(htmlString)

    WebView.loadHTMLString(htmlString, baseURL: urlJS)

    相关文章

      网友评论

          本文标题:Swift - WebView 加载 Html [String

          本文链接:https://www.haomeiwen.com/subject/pptljttx.html