Ios swift 3-如何关闭网络视图中的页面(选项卡)
在viewcontroller中,我使用此代码打开本地html文件Ios swift 3-如何关闭网络视图中的页面(选项卡),ios,xcode,webview,swift3,Ios,Xcode,Webview,Swift3,在viewcontroller中,我使用此代码打开本地html文件 self.webView = WKWebView(frame: webFrame, configuration: config) self.webView?.uiDelegate = self as? WKUIDelegate self.webView?.navigationDelegate = self self.webView?.scrollView.bounces = false self.container!.add
self.webView = WKWebView(frame: webFrame, configuration: config)
self.webView?.uiDelegate = self as? WKUIDelegate
self.webView?.navigationDelegate = self
self.webView?.scrollView.bounces = false
self.container!.addSubview(webView!)
let testUrl: URL! = Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "assets")
self.webView!.loadFileURL(testUrl, allowingReadAccessTo: testUrl)
通过safari在菜单“开发人员”>“模拟器”中调试显示打开的页面(index.html)。每次我离开此viewControler并返回时,都会在菜单“开发人员”>“模拟器”中添加一个新页面(index.html,index.html,…)。我相信新的页面是在新的标签中打开的
在用于退出此viewController的函数中,我使用以下代码
self.webView?.removeFromSuperview()
self.container.removeFromSuperview()
对象已删除,但页面未删除,有人知道如何删除它们吗