#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 高度 准确,留有空白的解决方案的更多相关文章

  1. iOS WKWebview 网页开发适配指南

    iOS WKWebview 网页开发适配指南 微信iOS客户端将于2017年3月1日前逐步升级为WKWebview内核,需要网页开发者提前做好网站的兼容检查和适配.如有问题,可参考文末联系方式,向我们 ...

  2. ActionBar设置自定义setCustomView()留有空白的问题

    先来看问题,当我使用ActionBar的时候,设置setCustomView时,会留有空白的处理 网上很多朋友说可以修改V7包到19,结果处理的效果也是不理想的. 下面贴出我觉得靠谱的处理代码 pub ...

  3. inline-block元素的4px空白间距解决方案

    http://www.jb51.net/css/68785.html  inline-block元素的4px空白间距解决方案 

  4. inline元素和inline-block元素的4px空白间距解决方案

    实在不想写了,要吐了,看到一篇讲的比较全的文章,直接粘链接了 inline元素和inline-block元素的4px空白间距解决方案 出自脚本之家

  5. 驰骋工作流引擎-CCMobile与安卓、IOS集成过程中的问题与解决方案

    CCMobile与安卓.IOS集成过程中的问题与解决方案 前言: CCMobile(2019版本)是CCFlow&JFlow 的一款移动端审批的产品.系统基于mui框架开发,是一款可以兼容An ...

  6. MUI - myStorage在ios safari无痕浏览模式下的解决方案

    myStorage在ios safari无痕浏览模式下的解决方案 今天看到了这个帖子LocalStorage 在 Private Browsing 下的一个限制, 吓尿了,如果用户开启了无痕浏览,ap ...

  7. iOS WKWebView的javascript alert 不弹的解决方案

    - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiate ...

  8. ios下fixed回复框bug的解决方案

    前几天做一个移动端的页面,要加个像微信那样附着在底部的回复框,按照做PC端网页的思路,首先是用fixed,在安卓上测了一下是好的,结果到朋友的iphone6p上就不行了,点击输入框之后它总会跳到屏幕中 ...

  9. 微信iOS WKWebview 网页开发适配指南

    微信iOS客户端将于2017年3月1日前逐步升级为WKWebview内核,需要网页开发者提前做好网站的兼容检查和适配. 背景 WKWebView 是苹果在iOS 8中引入的新组件,目的是提供一个现代的 ...

随机推荐

  1. http://blog.csdn.net/tkwxty/article/details/34474501

    http://blog.csdn.net/tkwxty/article/details/34474501

  2. onvif 协议

    1.ONVIF 协议解读 https://www.onvif.org 一.什么是ONVIF? 1.1形成 2008年5月,由安讯士(AXIS)联合博世(BOSCH)及索尼(SONY)公司三方宣布携手共 ...

  3. [TypeScript] Deeply mark all the properties of a type as read-only in TypeScript

    We will look at how we can use mapped types, conditional types, self-referencing types and the “infe ...

  4. [TypeScript] Custom data structures in TypeScript with iterators

    We usually think of types as something that can define a single layer of an object: with an interfac ...

  5. zbar 解析 图片 二维码 条形码

    #!/usr/bin/env python # coding: u8 import os import zbar import Image import urllib import uuid def ...

  6. libevent2源码分析之一:前言

    event的本质 libevent2中的event的本质是什么?只要是非同步阻塞的运行方式,肯定遵循事件的订阅-发布模型.通过event_new的函数原型可以理解,一个event即代表一次订阅,建立起 ...

  7. Linux 多线程环境下 进程线程终止函数小结(转)

    pthread_kill: pthread_kill与kill有区别,是向线程发送signal.,大部分signal的默认动作是终止进程的运行,所以,我们才要用signal()去抓信号并加上处理函数. ...

  8. 【Java】Java_14 循环结构

    循环结构 当型:当P条件成立时(T),反复执行A,直到P为“假”时才停止循环. 直到型:先执行A, 再判断P,若为T,再执行A,如此反复,直到P为F. 1.While循环 while循环的基本格式和流 ...

  9. loadrunner使用sitescope监测监控mysql数据库

    分类: LoadRunner 性能测试 2012-11-22 00:14 2644人阅读 评论(0) 收藏 举报 loadrunnerLoadRunnermysqlMySQLMysqlMYSQLMyS ...

  10. oci pool

    http://wenku.baidu.com/link?url=uS8tWxcs7MxNdx5HiGCEyvXsCj0zF5-7pCRVQtlRH5eVuMmSKKqNziSc2O_pyepnnuc_ ...