IT虾米网

UIWebView自适应内容的高度

luoye 2018年06月24日 手机开发 993 0
 
 
//自适应文字的高度 
 
- (void)webViewDidFinishLoad:(UIWebView *)webView 
 
{ 
 
 
    NSString *height_str= [webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"]; 
 
    int height = [height_str intValue]; 
 
    webView.frame = CGRectMake(0,titleLabel.frame.origin.y+titleLabel.frame.size.height+5,SCREEN_WIDTH-20,height+30); 
 
    timeLabel.frame=CGRectMake(20, webView.frame.origin.y+webView.frame.size.height+5, SCREEN_WIDTH-10-10, 20); 
 
    background.frame = CGRectMake(10, 20, SCREEN_WIDTH-20, timeLabel.frame.origin.y+timeLabel.frame.size.height+5); 
 
    NSLog(@"height: %@", [webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"]); 
 
} 

评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

iOS调用相册和摄像头