Ste*_*hey 11 xcode webkit objective-c uiwebview ios
在UIWebView,添加UIDataDetectorTypes到视图相当容易:
myUIWebView.dataDetectorTypes = UIDataDetectorTypePhoneNumber;
Run Code Online (Sandbox Code Playgroud)
等等.但是,WKWebView似乎没有类似的属性.该参考文献提到它已移至该WKWebViewConfiguration属性myWebKitView.configuration,但官方文档和标题本身都没有引用dataDetectorTypes.
我目前正在尝试将应用程序从使用迁移UIWebView到WKWebView,此应用程序目前具有用户可配置的功能UIDataDetectorTypes.那么,有没有办法使用提供的API实现它,或者我是否必须编写自己的代码来解析HTML?
ara*_*_86 19
实际上WKwebView没有dataDetectorTypes属性.但在iOS 10 WKWebViewConfiguration中有.
请尝试以下代码段.
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
theConfiguration.dataDetectorTypes = WKDataDetectorTypeNone;
WKWebView *webView = [[WKWebView alloc] initWithFrame:_someFrame configuration:theConfiguration];
Run Code Online (Sandbox Code Playgroud)
这仅适用于iOS10以上版本.
引用的文章已经更新,以反映iOS 8测试版之间API的变化.从8.0.1开始,没有任何dataDetectorTypes属性WKWebView,没有其他类似的公共API.
在将它添加回类之前,您必须自己使用NSDataDetector实现它,或者让自己辞职UIWebView.
| 归档时间: |
|
| 查看次数: |
5279 次 |
| 最近记录: |