一个用于在您的应用内显示网页的非常简单的 modal webview。
example.mp4
modal_webview 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中。
pod 'modal_webview'
在导入库 import modal_webview
后,实例化类并调用 show
方法
class ViewController: UIViewController {
let webview = ModalWebview()
var url = URL(string: "https://developer.apple.com/")!
func showBrowserAction(){
webview.show(controller: self, url: url)
}
}
您可以通过实现代理来轻松跟踪在 webView 中发生的事件
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
webview.delegate = self
}
}
extension ViewController: ModalWebviewProtocol{
func didClose() {
print("Closed")
}
func didFailOpenUrl(){
print("Did failed to open URL")
}
}
João Morais,[email protected]
modal_webview 在 MIT 许可协议下提供。有关更多信息,请参阅 LICENSE 文件。