1. Create and load the UIWebView in the Loadview method first
-(void) loadview{ [[UIWebView alloc]init];//So there will only be one view} on the controller
2. Set the execution path of the WebView
-(void) viewdidload{ [Super Viewdidload]; 3, loading web interface UIWebView *webview = (UIWebView *) Self.view; Webview.delegate = self;// 3.1 Gets the full path of the file nsstring *fullpath = [[NSBundle mainbundle]pathforresource: self.helpModel.html oftype:nil];// 3.2 Get URL nsurl * url = [[Nsurl alloc]initfileurlwithpath:fullpath];// 3.3 Get Request nsurlrequest *request = [[nsurlrequest alloc]initwithurl:url];// 3.4 load [WebView Loadrequest:request]; }
3. When the page is loaded, execute the JavaScript code and jump to the corresponding location
In the WebView proxy method--webviewdidfinishload inside the execution
Generate the corresponding JavaScript code nsstring *jsstr = [NSString stringwithformat:@ "window.location.href = ' #%@ ';", SELF.HELPMODEL.TAGID]; Stringbyevaluatingjavascriptfromstring:jsstr];