Transferred from: http://www.cnblogs.com/gcb999/p/3178728.html
Framework: WebView and JS communication framework
#import "MJViewController.h" #import "Mbprogresshud+add.h" @interface Mjviewcontroller () @end @implementation mjviewcontroller-(void) viewdidload{[Super Viewdidload]; [Self loadremotehtml];} #pragma mark loads the remote HTML page-(void) loadremotehtml {nsurl *url = [Nsurl urlwithstring:@ "Http://192.168.1.106:8080/MJServer /"]; Self.webView.delegate = self; [Self.webview loadrequest:[nsurlrequest requestwithurl:url];} #pragma mark load other files-(void) Loadremotetxt {nsurl *url = [Nsurl urlwithstring:@ "http://192.168.1.106:8080/MJServer/abc.t XT "]; Self.webView.delegate = self; [Self.webview loadrequest:[nsurlrequest requestwithurl:url];} #pragma mark load PDF file-(void) loadlocalpdf {//[self.webview loaddata:<# (NSData *) #> mimetype:<# (NSString *) #> ; textencodingname:<# (NSString *) #> baseurl:<# (Nsurl *) #>]; Nsurl *url = [Nsurl fileurlwithpath:@ "/users/apple/desktop/10th-Network. pdf"]; Self.webView.delegate = self; [Self.webview Loadrequest:[nSurlrequest Requestwithurl:url]];} #pragma mark Load HTML string-(void) loadhtmlstring {nsurl *url = [Nsurl fileurlwithpath:@ "/users/apple/pictures"]; [Self.webview loadhtmlstring:@ "Usage of the service side
Advanced usage of WebView in iOS