Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITablewViewCell中的可调整大小的UIWebView/WKWebView内容视图_Ios_Swift_Uitableview_Uiwebview_Key Value Observing - Fatal编程技术网

Ios UITablewViewCell中的可调整大小的UIWebView/WKWebView内容视图

Ios UITablewViewCell中的可调整大小的UIWebView/WKWebView内容视图,ios,swift,uitableview,uiwebview,key-value-observing,Ios,Swift,Uitableview,Uiwebview,Key Value Observing,我在UITableViewCell中有UIWebView(例如的url:,它具有可调整大小的内容高度)。 所以我观察它的大小 func startObservingHeight() { let options = NSKeyValueObservingOptions([.new]) webView.addObserver(self, forKeyPath: "scrollView.contentSize", options: options, context: nil) } 所以,

我在UITableViewCell中有UIWebView(例如的url:,它具有可调整大小的内容高度)。 所以我观察它的大小

func startObservingHeight() {
   let options = NSKeyValueObservingOptions([.new])
   webView.addObserver(self, forKeyPath: "scrollView.contentSize", options: options, context: nil)
}
所以,只有当webView的contentSize增长时,才会调用下面的代码。所以我增加了我的tableViewCell,当我缩小html文档的某些部分(css更改)时,下面的函数不调用,并且我无法调整单元格的大小

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {        
  if let zeChange = change as? [NSKeyValueChangeKey: NSValue] {
    let newSize = zeChange[NSKeyValueChangeKey.newKey]?.cgSizeValue
    changeHeight?(newSize.height)
  }
}
这是我的回调变量:

var changeHeight: ((CGFloat?) -> ())?