Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
502 views
in Technique[技术] by (71.8m points)

ios - How to download a page in swift2 without using third party libraries?

I am trying to show the downloaded HTML page in the app. Please explain the simplest way to do so without using any third party libraries.

cheers,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can show a html page in app without downloading

 let pageUrl = NSURL (string: "http://www.stackoverflow.com");
 let req = NSURLRequest(URL: url!);

if you want to show a local file you show like this

let htmlfilePath = NSBundle.mainBundle().URLForResource("filename", withExtension: "html");
    let req = NSURLRequest(URL: htmlfilePath !);
    webview.loadRequest(req);

to download a file you can use plain NSURLSession


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...