-
iOS) wkWebview(webview) 뒤로가기, 앞으로가기 기능 구현 (Swift)Programing Language/iOS(Swift) 2020. 3. 11. 19:01728x90반응형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
필수 delegate webview.uiDelegate = self webview.navigationDelegate = self 필요한 델리게이트 메서드 extension ViewController : WKUIDelegate, WKNavigationDelegate { func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { back_btn.isEnabled = webView.canGoBack forward_btn.isEnabled = webView.canGoForward } } //MARK: - @objc 모음 메서드 extension wkwebViewController { @objc func backButtonAction() { if self.webview.canGoBack{ self.webview.goBack() } } @objc func forwardButtonAction() { if self.webview.canGoForward { webview.goForward() } } } 이후 @objc 메서드들을 버튼에 넣어준다. forward_btn.addTarget(self, action: #selector(forwardButtonAction), for: .touchUpInside) back_btn.addTarget(self, action: #selector(backButtonAction), for: .touchUpInside) 728x90반응형'Programing Language > iOS(Swift)' 카테고리의 다른 글
iOS) 특정 ViewController에서 상단에 navigationbar 숨기고 popGesture로 이전뷰로 돌아가기 (0) 2020.03.12 iOS ) 특정 ViewController에서 navigationBar 숨기기 (0) 2020.03.12 iOS) 네비게이션 컨트롤러 programmatically으로 설정하기 (Swift5 최신) (0) 2020.03.11 iOS) http 허용하기 info.plist 수정 (0) 2020.03.11 iOS) UIButton에 이미지와 텍스트 넣기[펌] (0) 2020.03.09