iOS 개발:UIWebView 의 간단 한 사용

1917 단어 ios 개발
1.UIWebView 의 사용
UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 400)];
    NSString * str = @"http://www.baidu.com";
    NSURL * url = [NSURL URLWithString:str];
    NSURLRequest * requst = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requst];
    webView.delegate = self;

2.UIWebView 의 에이전트 방법
<UIWebViewDelegate>
//      
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    
    return YES;
}

//      
-(void)webViewDidStartLoad:(UIWebView *)webView{
    
}

//      
-(void)webViewDidFinishLoad:(UIWebView *)webView{
    
// cell   webView        
//    CGFloat scrollHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];
    //        webview   
    CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"] floatValue];
    
    CGRect frame = webView.frame;
    frame.size.height = height;
    webView.frame = frame;
    
//  cell   
    _webViewHeight = height;
    [self.tableView beginUpdates];
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
    [self.tableView endUpdates];
   
}


//      
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    
    
}

3.UIWebView 의 다른 방법
//       
    webView.scalesPageToFit =YES;
    //           
    webView.scrollView.showsHorizontalScrollIndicator = NO;
    //           
    webView.scrollView.showsVerticalScrollIndicator = NO;
    //      
    webView.scrollView.scrollEnabled = NO;

좋은 웹페이지 즐겨찾기