IOS Webview 관련해서 간단한 예제입니다.
저 버튼을 누르면 브라우저에서 뭔가가 띄워지도록 처리하면

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import SafariServices | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
} | |
@IBAction func webviewButton(_ sender: Any) { | |
let vc = SFSafariViewController(url: URL(string: "https://www.apple.com")!) | |
present(vc, animated: true) | |
} | |
} |

이렇게 할 수 있고, 범위를 지정해서 webview를 틀려고 하면
아래와 같이 스토리보드에서 넣고


코드를 이렇게하면
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import WebKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var webview: WKWebView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
webview.load(URLRequest(url: URL(string: "https://www.google.com")!)) | |
} | |
} |

'IOS(Swift)' 카테고리의 다른 글
Custom TableView (0) | 2021.01.27 |
---|---|
IOS 앱 런칭을 위한 사이즈 (0) | 2021.01.24 |
Swift CollectionView (0) | 2021.01.03 |
IOS ImageView Click (0) | 2021.01.01 |
IOS Admob달기 (0) | 2021.01.01 |