webView的常用属性
self.webView.scrollView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0);
self.webView.scalesPageToFit = YES;//自适应布局
self.webView.dataDetectorTypes = UIDataDetectorTypeAll;//可以识别号码、链接等等
webView的代理
-(void)test
{
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]];
//设置代理
self.webView.delegate = self;
}
#pragma mark ----------------------
#pragma mark UIWebViewDelegate
//2
-(void)webViewDidStartLoad:(UIWebView *)webView
{
NSLog(@"webViewDidStartLoad");
}
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSLog(@"webViewDidFinishLoad");
self.goBack.enabled = self.webView.canGoBack;
self.goforward.enabled = self.webView.canGoForward;
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"didFailLoadWithError");
}
//1
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSLog(@"%@",request.URL.absoluteString);
return NO;
}