LoginSignup
0
1

More than 3 years have passed since last update.

【Swift】他クラスのデリゲートを自分のメソッドで使用する方法

Posted at

1、自分のクラスで使えるように宣言をする
class ViewController: UIViewController, WKNavigationDelegate {

2、自分のクラスで使えるように設定する
webView.navigationDelegate = self

3、記述する
// ロードが開始された時
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation){
print("読み込み開始")
indicator.startAnimating()
}

// ロードが完了した時
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation){
print("読み込み終了")
indicator.stopAnimating()
}

※単語はそれぞれ名前を書く必要あり

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1