iOS 프로그래밍: 간단한 웹뷰 앱 만들기
iOS 프로그래밍: 간단한 웹뷰 앱 만들기
info.plist 편집
기본적으로 HTTPS 웹 사이트만 지원합니다. HTTP의 경우 위의 설정을 하지 않으면 웹사이트가 앱에 나타나지 않습니다.
스토리보드 작성 및 ViewController.swift 편집
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import UIKit
import WebKit
class ViewController: UIViewController {
@IBOutlet weak var wvMain: WKWebView!
func goWeb(postfix: String) -> () {
let url = URL(string: "http://examplewebsite.con/music/\(postfix)")
let request = URLRequest(url: url!)
wvMain.load(request)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
goWeb(postfix: "scale")
}
@IBAction func btnScale(_ sender: UIButton) {
goWeb(postfix: "scale")
}
@IBAction func btnFreq(_ sender: UIButton) {
goWeb(postfix: "freq")
}
}
결과 확인
웹뷰앱만들기 아이오에스 iOS 웹뷰 만들기 WebView
This post is licensed under
CC BY 4.0
by the author.



