ios -WKWebView 高度 准确,留有空白的解决方案
#import "ViewController.h"
#import <WebKit/WebKit.h>
@interface ViewController ()<WKNavigationDelegate>
@property (nonatomic, strong)WKWebView *webView;
@end
@implementation ViewController
- (void)viewDidLoad
{
_webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 1)];
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
[self.view addSubview:_webView];
NSString *url = [NSString stringWithFormat:@"https://mdetail.tmall.com/templates/pages/desc?id=13128565333"];
NSLog(@"dfurk:%@",url);
[self.webView loadRequest:[[NSURLRequest alloc] initWithURL:[NSURL URLWithString:url]]];
[self.webView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)dealloc {
[self.webView.scrollView removeObserver:self forKeyPath:@"contentSize" context:nil];
}
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if (object == self.webView.scrollView && [keyPath isEqual:@"contentSize"]) {
// we are here because the contentSize of the WebView's scrollview changed.
UIScrollView *scrollView = self.webView.scrollView;
self.webView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
NSLog(@"New contentSize: %f x %f", scrollView.contentSize.width, scrollView.contentSize.height);
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
ios -WKWebView 高度 准确,留有空白的解决方案的更多相关文章
- iOS WKWebview 网页开发适配指南
iOS WKWebview 网页开发适配指南 微信iOS客户端将于2017年3月1日前逐步升级为WKWebview内核,需要网页开发者提前做好网站的兼容检查和适配.如有问题,可参考文末联系方式,向我们 ...
- ActionBar设置自定义setCustomView()留有空白的问题
先来看问题,当我使用ActionBar的时候,设置setCustomView时,会留有空白的处理 网上很多朋友说可以修改V7包到19,结果处理的效果也是不理想的. 下面贴出我觉得靠谱的处理代码 pub ...
- inline-block元素的4px空白间距解决方案
http://www.jb51.net/css/68785.html inline-block元素的4px空白间距解决方案
- inline元素和inline-block元素的4px空白间距解决方案
实在不想写了,要吐了,看到一篇讲的比较全的文章,直接粘链接了 inline元素和inline-block元素的4px空白间距解决方案 出自脚本之家
- 驰骋工作流引擎-CCMobile与安卓、IOS集成过程中的问题与解决方案
CCMobile与安卓.IOS集成过程中的问题与解决方案 前言: CCMobile(2019版本)是CCFlow&JFlow 的一款移动端审批的产品.系统基于mui框架开发,是一款可以兼容An ...
- MUI - myStorage在ios safari无痕浏览模式下的解决方案
myStorage在ios safari无痕浏览模式下的解决方案 今天看到了这个帖子LocalStorage 在 Private Browsing 下的一个限制, 吓尿了,如果用户开启了无痕浏览,ap ...
- iOS WKWebView的javascript alert 不弹的解决方案
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiate ...
- ios下fixed回复框bug的解决方案
前几天做一个移动端的页面,要加个像微信那样附着在底部的回复框,按照做PC端网页的思路,首先是用fixed,在安卓上测了一下是好的,结果到朋友的iphone6p上就不行了,点击输入框之后它总会跳到屏幕中 ...
- 微信iOS WKWebview 网页开发适配指南
微信iOS客户端将于2017年3月1日前逐步升级为WKWebview内核,需要网页开发者提前做好网站的兼容检查和适配. 背景 WKWebView 是苹果在iOS 8中引入的新组件,目的是提供一个现代的 ...
随机推荐
- js/jquery循环提取table单元格值
<table id="tbitem"> <tr><td>测试数据1</td></tr> <tr><td ...
- http://www.oschina.net/question/1019034_153316
http://www.oschina.net/question/1019034_153316 http://www.oschina.net/question/97503_212116?sort=tim ...
- Linux启动U盘制作
Linux目前最好的u盘启动工具之一,下面介绍它的用法,首先下载Linux live OK了,一步一步跟我步骤走! 启动时,选择需要用的U盘 步骤二,就选择安装源即可(一般为ISO文件) 最后进行步骤 ...
- 压测过程中,CPU和内存占用率很高,案例简单分析
Q: 最近公司测试一个接口,数据库采用Mongo 并发策略:并发400个用户,每3秒加载5个用户,持续运行30分钟 数据量:8000条左右 压测结果发现: TPS始终在5左右 ...
- ActiveMQ与MSMQ的异同
http://www.cnblogs.com/luluping/archive/2010/11/03/1867841.html 目前常用的消息队列组建无非就是MSMQ和ActiveMQ,至于 ...
- select/poll/epoll原理探究及总结
select,poll,epoll都是IO多路复用的机制.I/O多路复用就通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知程序进行相应的读写操作.但select ...
- NodeJS在CentOs7下安装
node下载地址:https://nodejs.org/en/download/ 1.安装gcc $ yum install gcc-c++ 2.解压最新版本 $ mkdir /usr/local/n ...
- 【CODEFORCES】 C. Table Decorations
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 安装ecshop默认安装后的错误解决方案
1,统一解决 php.ini中的配置 error_reporting = E_ALL | E_STRICT 这是说,显示那些不符合编码规范的警告(coding standards warnings). ...
- nginx 根据域名反向代理
#nginx 反向代理域名,会根据启动时候解析出来的ip,加载到内存中,后面不会改变可以绑定hosts或者指定resolve服务器来固定ip #注意proxy最后的斜杠,如果不加会将请求过来的目录带到 ...