Код: Выделить всё
Here is some images
1
[img]img/1.jpg[/img]
2
[img]./img/1.jpg[/img]
3
[img]2.jpg[/img]
< /code>
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
Text("Hello, world!")
HTMLView(fileName: "index")
}
.padding()
}
}
struct HTMLView: UIViewRepresentable {
let fileName: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ webView: WKWebView, context: Context) {
//TRIED THIS
// guard let url = Bundle.main.url(forResource: fileName, withExtension: "html") else { return }
// guard let htmlString = try? String(contentsOf: url, encoding: .utf8) else { return }
// webView.loadHTMLString(htmlString, baseURL: url)
//AND TRIED THIS
// let url = Bundle.main.url(forResource: "index", withExtension: "html")!
// webView.loadFileURL(url, allowingReadAccessTo: url)
// AND TRIED THIS
let url = Bundle.main.url(forResource: "index", withExtension: "html")!
webView.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent())
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... irectories