怎样获取UIWebView 的文字的高度
展开全部
#import"ViewController.h"
@interfaceViewController()
@property(nonatomic,strong)UIWebView*webView;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
_webView= [[UIWebViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,1)];// 1随便多少,不能为0
_webView.delegate=self;
[self.viewaddSubview:_webView];
_webView.scalesPageToFit=YES;
NSURLRequest*request =[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://192.168.1.123:3199/html5/Html5Article/ArticleDetail?aid=7e15de0a-20be-11e6-a7ad-78e3b5a9d432"]];
[_webViewloadRequest:request];
}
- (void)webViewDidFinishLoad:(UIWebView*)webView{
CGFloatsizeHeight = [[webViewstringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"]floatValue];
NSLog(@"contentWebView sizeHeight====%f",sizeHeight *0.5);// 0.5自认为是像素的问题.
@interfaceViewController()
@property(nonatomic,strong)UIWebView*webView;
@end
@implementationViewController
- (void)viewDidLoad {
[superviewDidLoad];
_webView= [[UIWebViewalloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width,1)];// 1随便多少,不能为0
_webView.delegate=self;
[self.viewaddSubview:_webView];
_webView.scalesPageToFit=YES;
NSURLRequest*request =[NSURLRequestrequestWithURL:[NSURLURLWithString:@"http://192.168.1.123:3199/html5/Html5Article/ArticleDetail?aid=7e15de0a-20be-11e6-a7ad-78e3b5a9d432"]];
[_webViewloadRequest:request];
}
- (void)webViewDidFinishLoad:(UIWebView*)webView{
CGFloatsizeHeight = [[webViewstringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight;"]floatValue];
NSLog(@"contentWebView sizeHeight====%f",sizeHeight *0.5);// 0.5自认为是像素的问题.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询