zoukankan      html  css  js  c++  java
  • WKWebView加载显示问题

    改用WKWebView,但是加载的时候页面的行高显示的是正确的,但是里面的数据一直显示不全;

    出现问题的原因:  WKWebView放置的位置,在加载cell的时候,直接放在cell的contentView

    2》  设置观察者

            [self.detailWebView.scrollView addObserver:self forKeyPath:@"contentSize" options:NSKeyValueObservingOptionNew context:nil];

    3》在观察方法中设置为WKWebView的frame

    - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void *)context {

    CGSize websize = [[change objectForKey:@"new"] CGSizeValue];

    self.detailWebView.frame = CGRectMake(0, 0, ScreenWidth, websize.height);

    [self.cellHeightArr replaceObjectAtIndex:1 withObject:@(websize.height)];

    NSIndexPath*index=[NSIndexPath indexPathForRow:0 inSection:self.saveCellArrM.count-1];

    [self.tableView reloadRowsAtIndexPaths:@[index] withRowAnimation:UITableViewRowAnimationNone];

    }

     3》 每次值改变的时候,重新设置加载cell,设置cell的高度

     4》 结论:cell的行高是页面内容的高度,可是在加载后,页面中的数据有时能显示完整,有时显示不完整


    解决办法:

    1》 在cell上加载一个scrollView,再将WKWebView加载到scrollView上,让后在每次加载cell的时候,设置scrollView的高度为页面的高度(最主要的就是不能将WKWebView直接放在cell上

    2》其它的设置不变

    3》结论:加载显示。

    PS: (目前发现只有在iOS 10以上系统 会出现问题 有谁知道更好的解决办法或者别的  欢迎留言  )

  • 相关阅读:
    栈和队列
    数组的遍历查找
    字符串的子串
    两个字符串
    字符串的遍历
    字符串的替换
    数组和矩阵
    Django 自带的ORM增删改查
    what's the CRSF ??
    Rabbitmq -Publish_Subscribe模式- python编码实现
  • 原文地址:https://www.cnblogs.com/LynnAIQ/p/6278361.html
Copyright © 2011-2022 走看看