***********
#import "HMViewController.h"@interfaceHmviewcontroller () <UIWebViewDelegate>@end@implementationHmviewcontroller- (void) viewdidload{[Super Viewdidload]; //1.webViewUIWebView *webview =[[UIWebView alloc] init]; Webview.frame=Self.view.bounds; WebView.Delegate=Self ; [Self.view Addsubview:webview]; //2. Loading Web pagesNsurl *url = [[NSBundle mainbundle] Urlforresource:@"Test"Withextension:@"HTML"]; Nsurlrequest*request =[Nsurlrequest Requestwithurl:url]; [WebView loadrequest:request];}#pragmamark-uiwebviewdelegate-(void) Webviewdidfinishload: (UIWebView *) webview{}/** * WebView This method is called every time a request is sent (can intercept all requests)*/-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (Nsurlrequest *Request Navigationtype: (uiwebviewnavigationtype) navigationtype{nsstring*url =request. url.absolutestring; Nsrange Range= [url rangeofstring:@"hm://"]; Nsuinteger Loc=range.location; Locationif(loc! = nsnotfound) {//the protocol header for the URL is HM//Method NameNSString *method = [url Substringfromindex:loc +Range.length]; //turn into SELSel sel =nsselectorfromstring (method); //method = "Call" or "Opencamera" [Self Performselector:sel withobject:nil]; } returnYES;}/** * Call*/- (void) call{NSLog (@"Call ----");}/** * Open the camera*/- (void) opencamera{NSLog (@"Opencamera----");}@end
The code in WebView is called in the iOS network Seventh day Webview-03js