Eri*_*les 3 uiwebview ios swift swift3
我正在将应用程序迁移到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)
我愿意接受建议,谢谢.
案件需要
case("contentSize", .some(&MyObservationContext)):
Run Code Online (Sandbox Code Playgroud)
.some 是为了确保上下文不是零
&获取指针,MyObservationContext以便它可以比较指针指针.
| 归档时间: |
|
| 查看次数: |
2896 次 |
| 最近记录: |