I have doubt that how i can i create a webview using button click as same as javascript. I have searched alot but no result please if anyone have idea on that please send me simple code on creating webview in button click
Accepted Reply
You will get more focused answers if you move this post to the right sction of forum, SwiftUI.
In the meantime, ddi you see this:
https://forums.developer.apple.com/thread/123139
Following the thread will give you some sample code:
import SwiftUI
import WebKit
struct WebView : UIViewRepresentable {
let request: URLRequest
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(request)
}
}
#if DEBUG
struct WebView_Previews : PreviewProvider {
static var previews: some View {
WebView(request: URLRequest(url: URL(string: "https://www.apple.com")!))
}
}
#endif
This other one may give some hints, but use some deprecated API, so cannot be used directly.
h ttps://github.com/kylehickinson/SwiftUI-WebView
Replies
You will get more focused answers if you move this post to the right sction of forum, SwiftUI.
In the meantime, ddi you see this:
https://forums.developer.apple.com/thread/123139
Following the thread will give you some sample code:
import SwiftUI
import WebKit
struct WebView : UIViewRepresentable {
let request: URLRequest
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ uiView: WKWebView, context: Context) {
uiView.load(request)
}
}
#if DEBUG
struct WebView_Previews : PreviewProvider {
static var previews: some View {
WebView(request: URLRequest(url: URL(string: "https://www.apple.com")!))
}
}
#endif
This other one may give some hints, but use some deprecated API, so cannot be used directly.
h ttps://github.com/kylehickinson/SwiftUI-WebView
bro thanks for your suggestion