Swift - WebView 加载 Html [String + filePath]

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 + filePath])