我正在将应用程序迁移到Swift 3,但是Xcode在这个函数中抛出一个错误:
错误是在案例条件("contentSize",MyObservationContext)我这样做是为了更新uiwebview的内容大小
var MyObservationContext = 0
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard let keyPath = keyPath else {
super.observeValue(forKeyPath: nil, of: object, change: change, context: context)
return
}
switch (keyPath, context) {
case("contentSize", MyObservationContext):
webviewHeightConstraint.constant = TextoHtml.scrollView.contentSize.height
default:
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
Run Code Online (Sandbox Code Playgroud)
我愿意接受建议,谢谢.