webview的几种用法

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Cai_guange1226/article/details/50426090

第一种:直接加载html的web view
- (void)loadWebView{
UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
webView.scalesPageToFit =YES;
[webView loadHTMLString:content baseURL:nil];
[self.view addSubview:webView];
}
第二种:post传参加载web view
UIWebView *WebView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
[WebView setScalesPageToFit:YES];
[self.view addSubview:WebView];
NSString *url = [NSString stringWithFormat:@”%@bei/page.html”,K_URL];
NSString *body = [NSString stringWithFormat:@”%@”,string];//body即为要传的参数
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @”POST”];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion:YES]];
WebView.delegate = self;
[WebView loadRequest: request];

展开阅读全文

没有更多推荐了,返回首页