본문 바로가기
IOS

ios WKWebView 띄워보기 (웹뷰)

by 일용직 코딩노동자 2020. 5. 7.
728x90
반응형
import UIKit
import WebKit

class ViewController: UIViewController,WKUIDelegate {

    @IBOutlet weak var mWebView: WKWebView!
    
    override func loadView() {
        let webConfiguration = WKWebViewConfiguration()
        mWebView = WKWebView(frame: .zero, configuration: webConfiguration)
        mWebView.uiDelegate = self
        view = mWebView
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        if let myURL = URL(string:"https://www.google.com") {
            let myRequest = URLRequest(url: myURL)
            mWebView.load(myRequest)
        }
    }
}

스토리보드에서 WebView를 이어주시구요.

 

초기 WebView셋팅을 해줍니다. 

 

해당역할은 loadView가 해줍니다.

 

 

728x90
반응형

댓글