UIWebView内嵌网页 Xcode7.0以后的用法

UIWebView* webPage=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight-64)];

NSURL* url=[[NSURL alloc]initWithString:@"http://www.baidu.com"];

NSURLRequest* request=[[NSURLRequest alloc]initWithURL:url];

[webPage loadRequest:request];

webPage.scalesPageToFit=YES;

webPage.delegate=self;

[self.view addSubview:webPage];

 

<UIWebViewDelegate>中方法

- (void)webViewDidStartLoad:(UIWebView *)webView; //网页开始加载时候执行的方法

- (void)webViewDidFinishLoad:(UIWebView *)webView; //网页结束加载时候执行的方法

- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error; //网页加载失败时候执行的方法

 

Xcode7.0以后需要在Info.plist中加入以下属性 才能正确加载网页

注意NSAllows为App的子项

posted @ 2015-12-08 15:00  death3721  阅读(373)  评论(0编辑  收藏  举报