webView loads the url and loads the specified string

 

 

 


//Load url
-( void )addWebView{ UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, zScreenWidth, 480)]; NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@",URL]]]; webView.delegate=self; [self.view addSubview: webView]; self.HUB=[ZJStaticFunction showHubView:self.view]; if ([ZJStaticFunction isUserNetOK]) { [self.HUB show:YES]; [webView loadRequest:request]; }else{ [ZJStaticFunction alertView:self.view msg:remindNetWord]; } } // Let the browser load the specified string and use m.baidu.com to search - ( void )loadString:(NSString * )str { // 1. The URL locates the resource and needs the address of the resource NSString *urlStr = str; if (![str hasPrefix: @" http:// " ]) { urlStr = [NSString stringWithFormat:@"http://m.baidu.com/s?word=%@", str]; } NSURL *url = [NSURL URLWithString:urlStr]; // 2. Tell the server the URL, request, and request data from m.baidu.com NSURLRequest *request = [NSURLRequest requestWithURL:url]; // 3. Send a request to the server [self.webView loadRequest:request]; }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325900709&siteId=291194637