gpt4 book ai didi

ios - 以编程方式添加 WKWebView

转载 作者:行者123 更新时间:2023-12-01 19:40:47 25 4
gpt4 key购买 nike

我是iOS开发的新手,一直在用代码添加WKWebview时遇到困难。我也打算让它全宽,但我得到一个空屏幕。

var webView = WKWebView()
var activityIndicatorView: ActivityIndicatorView!

override func viewDidLoad() {
super.viewDidLoad()
//show Activity Indicator
self.activityIndicatorView = ActivityIndicatorView(title: "Loading content...", center: self.view.center)
self.activityIndicatorView.startAnimating();
self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())self.view.addSubview(self.activityIndicatorView.getViewActivityIndicator())
// Do any additional setup after loading the view.
let urlString = "http://www.youtube.com";
let request = URLRequest(url:URL(string: urlString)!)
self.webView.load(request)
self.view = webView
}

最佳答案

let webview = WKWebView()
webview.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 100)
webview.load(URLRequest(url: Bundle.main.url(forResource: "index", withExtension:"html", subdirectory: "subdirectories")! as URL) as URLRequest)
self.view.addSubview(webview)

关于ios - 以编程方式添加 WKWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53808681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com