UI/WKWebView|UI/WKWebView input file标签dismiss bug处理
iOS WebView 用标签打开系统相册会出现
dismiss
掉当前视图的bug,这是因为点击系统弹出的alertController时,会多次调用dismiss
(不知原因)。如果WebView自己或者根视图是通过present
出来的,则会被dismiss
掉,而用navigation
push
出来的则没有问题。
文章图片
解决办法
- 不使用
present
方式展示WebView - 用自定义
navigation
套着WebView,然后override
dismiss
方法
class WebViewNavigationController: UINavigationController {
override func dismiss(animated flag: Bool, completion: (() -> Void)? = nil) {
// fix webview input-file dismiss-twice bug
if let _ = self.presentedViewController {
super.dismiss(animated: flag, completion: completion)
}
}
}let webViewController
let nav = WebViewNavigationController(rootViewController: webViewController)
self.present(nav, animated: true, completion: nil)
【UI/WKWebView|UI/WKWebView input file标签dismiss bug处理】Read more
- https://stackoverflow.com/questions/37380333/modal-view-closes-when-selecting-an-image-in-wkwebview-ios
- https://stackoverflow.com/questions/35999551/uiimagepickercontroller-view-is-not-in-the-window-hierarchy
- http://www.jianshu.com/p/284405e7313d
- http://www.infocool.net/kb/IOS/201612/247812.html
推荐阅读
- 星际无限|星际无限 | 官方推出Filecoin MinerX奖学金计划,吸引中小型Filecoin矿工
- OC:|OC: WKWebView详解
- Filecoin挖矿投资报告
- WKWebview|WKWebview js 调用oc 和oc调用js
- cannot|cannot be read or is not a valid ZIP file
- 65|65 - Tips for File Handling
- PHP|PHP 扩展开发检测清单(扩展开发必读)
- linux监听蒲公英线程,重启
- Docker-Dockerfile
- iOS10|iOS10 WKWebView里的视频播放转屏适配