webview

如何用iOS获取网页请求

2016-07-23  本文已影响26人  hunterzhu

如今的App中有很多都是网页内嵌在App中的,今天就看看如何将网页内嵌进App.
1.创建一个webView的界面
2.获取连接
3.获取请求
4.调用请求
5.适配屏幕


    UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
    
    NSURL *url = [NSURL URLWithString:@"http://www.douyu.com"];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    [webView loadRequest:request];
    
    webView.scalesPageToFit = YES;
    
    [self.view addSubview:webView];

非常简单的代码

上一篇下一篇

猜你喜欢

热点阅读