博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
计算webView的高度
阅读量:7118 次
发布时间:2019-06-28

本文共 1250 字,大约阅读时间需要 4 分钟。

hot3.png

// index.html//html代码    
        
            John                : This is out Rich Text Editing View    //UIwebViewController 加载- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.        NSBundle *mainBundle = [NSBundle mainBundle];    NSURL *indexFileURL = [mainBundle URLForResource:@"index" withExtension:@"html"];    [self.webView loadRequest:[NSURLRequest requestWithURL:indexFileURL]];}- (void)webViewDidFinishLoad:(UIWebView *)wb{//计算高度的两个方法    //方法1    CGFloat documentWidth = [[wb stringByEvaluatingJavaScriptFromString:@"document.getElementById('content').offsetWidth"] floatValue];    CGFloat documentHeight = [[wb stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"content\").offsetHeight;"] floatValue];    NSLog(@"documentSize = {%f, %f}", documentWidth, documentHeight);        //方法2    CGRect frame = wb.frame;    frame.size.width = 768;    frame.size.height = 1;//    wb.scrollView.scrollEnabled = NO;    wb.frame = frame;        frame.size.height = wb.scrollView.contentSize.height;        NSLog(@"frame = %@", [NSValue valueWithCGRect:frame]);    wb.frame = frame;}

转载于:https://my.oschina.net/u/1782374/blog/625453

你可能感兴趣的文章
NOIP双栈排序
查看>>
tomcat 配置自签名ssl证书
查看>>
原型模式
查看>>
P3153 [CQOI2009]跳舞
查看>>
啥?客户叫在DataGridView的左上角添加CheckBox?
查看>>
第一次博客作业 <西北师范大学| 周安伟>
查看>>
C++ UI资源
查看>>
20135337——信息安全设计基础第十三周学习笔记
查看>>
gulp简介
查看>>
容器占用空间的小问题
查看>>
从加载的XML文档重建工作流
查看>>
Codeforces 349B - Color the Fence
查看>>
mysql分组查询前n条数据
查看>>
db2表空间自动扩展
查看>>
用Vue来实现音乐播放器(十七):歌手页右侧快速入口实现
查看>>
比原空投问答题库题解(一)
查看>>
[NOI2016]区间
查看>>
最大子数组问题
查看>>
HTTP-web服务器接收到client请求后的处理过程(很详细)
查看>>
面向对象进阶
查看>>