【发布时间】:2019-03-29 23:05:04
【问题描述】:
我对 Xcode 完全陌生,语法完全让我无法理解。
我还有一件事要做,然后我已经在 Xcode 中完成了我需要做的事情。
我需要插入一个允许 WebView 处理弹出窗口的函数,但我不知道从哪里开始插入代码。
这是当前代码:
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
override func viewDidLoad() {
super.viewDidLoad()
let webView = WKWebView()
let htmlPath = Bundle.main.path(forResource: "index", ofType: "html")
let folderPath = Bundle.main.bundlePath
let baseUrl = URL(fileURLWithPath: folderPath, isDirectory: true)
do {
let htmlString = try NSString(contentsOfFile: htmlPath!, encoding: String.Encoding.utf8.rawValue)
webView.loadHTMLString(htmlString as String, baseURL: baseUrl)
} catch {
// catch error
}
webView.navigationDelegate = self
view = webView
}
}
如何编辑它以允许弹出窗口?
请记住,我不知道如何添加我找到的解决方案,所以请告诉我在哪里插入 sn-p。
【问题讨论】:
标签: ios xcode wkwebview xcode9 popupwindow