• webView加载url,加载指定字符串



    //加载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]; } } // 让浏览器加载指定的字符串,使用m.baidu.com进行搜索 - (void)loadString:(NSString *)str { // 1. URL 定位资源,需要资源的地址 NSString *urlStr = str; if (![str hasPrefix:@"http://"]) { urlStr = [NSString stringWithFormat:@"http://m.baidu.com/s?word=%@", str]; } NSURL *url = [NSURL URLWithString:urlStr]; // 2. 把URL告诉给服务器,请求,从m.baidu.com请求数据 NSURLRequest *request = [NSURLRequest requestWithURL:url]; // 3. 发送请求给服务器 [self.webView loadRequest:request]; }
  • 相关阅读:
    leetcode
    Vim i和a差别
    HDU-4643-GSM(DFS)
    使用可编程电源自动化输出电源
    如何使用全局变量
    异步和同步
    启动界面
    鼠标右键弹出菜单
    Qt+excel
    Qt+数据库
  • 原文地址:https://www.cnblogs.com/OIMM/p/9009981.html
Copyright © 2020-2023  润新知