webview加载页面--

来源:互联网 发布:交换机端口流量监控 编辑:程序博客网 时间:2024/05/22 15:28

webview加载网页,这算是比较多的一种方式。昨天代码记录下。

  UIWebView *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds ].size.height)];        NSString *str =[NSString stringWithFormat:@"%@=%@",WinningUrl,self.join_user_id];        [self.view addSubview:webView];    self.webView = webView;    self.webView.scalesPageToFit = YES;//自动对页面进行缩放适应屏幕    NSURL *url = [NSURL URLWithString:str];    NSURLRequest* request = [NSURLRequest requestWithURL:url];//创建NSURLRequest    [webView loadRequest:request];



一定要记住,str变量,不要多出来空格,之前一直在纠结,怎么每次生成的request都是空的,后来发现在字符串末尾多了一个空格。

另外还有两个问题,需要解决:

(1)从别的页面跳转过来的时候,非常的缓慢。

(2)这个页面的webview是能动的,稍微一拖拽就能看到原生的背景。

0 0
原创粉丝点击