VesselWheel

[SwiftUI] webview 사용 코드 본문

Xcode Study

[SwiftUI] webview 사용 코드

JasonYang 2023. 4. 29. 14:12

https://stackoverflow.com/questions/73425418/type-videoview-does-not-conform-to-protocol-uiviewrepresentable

 

Type 'VideoView' does not conform to protocol 'UIViewRepresentable'

I'm trying to embed a YouTube video into my app and keep getting this error Type 'VideoView' does not conform to protocol 'UIViewRepresentable' here's my code: import SwiftUI import WebKit struct

stackoverflow.com

import SwiftUI

import WebKit

 

struct MyWebView: UIViewRepresentable {

    var urlToLoard: String

    

    func makeUIView(context: Context) -> WKWebView {

        guard let url = URL(string: self.urlToLoard)

        else {

            return WKWebView()

        }

        let webView = WKWebView()

        webView.load(URLRequest(url: url))

        return webView

    }

    func updateUIView(_ uiView: WKWebView, context: Context) {

        guard let baikURL = URL(string: "https://paikdabang.com/store") else {return}

                uiView.scrollView.isScrollEnabled = false

                uiView.load(URLRequest(url: baikURL))

    }

}

 

struct MyWebView_Previews: PreviewProvider {

    static var previews: some View {

        MyWebView(urlToLoard:"")

    }

}

 

'Xcode Study' 카테고리의 다른 글

Guard 문의 개념  (0) 2023.04.30
[SwiftUI] Allow Arbitrary Loads, 외부 URL 허용  (0) 2023.04.29
[SwiftUI] cocoapods 설치 및 사용  (0) 2023.04.29
[SwiftUI]switch 문의 개념  (0) 2023.04.26
[SwiftUI]if 문의 개념  (0) 2023.04.26