前提・実現したいこと
iOSアプリの開発をしています!
webViewで表示されたWebの画面でタッチイベントの処理を行いたいです!
今のところ、指定したURLをwebViewでネイティブの画面からWebの画面を表示させることはできていて、ネイティブの処理であるタッチイベント(touchesBegan(), touchesEnded())をWebの画面で処理させることができていません。。。
該当のソースコード
import UIKit import WebKit class ViewController: UIViewController, WKUIDelegate { var webView: WKWebView! override func loadView() { let webConfiguration = WKWebViewConfiguration() webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.uiDelegate = self view = webView } override func viewDidLoad() { super.viewDidLoad() let myURL = URL(string:"https://www.apple.com") let myRequest = URLRequest(url: myURL!) webView.load(myRequest) } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { print("Began") } override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) { } override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { print("Ended") } }
補足情報(FW/ツールのバージョンなど)
Xcode version 10.1
Swift version 4.2.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/17 15:24