Muhmud Jafr
Muhmud Jafr

Reputation: 41

Is there a way to make the WKWebview a firstResponder?

The Main idea is to reload the WKWebView if there is no touches or presses detected (i.e When webView remains inactive for some timeinterval ) . I tried the way to implement

touchesBegan(_:with:) and touchesEnded(_:with:)

I have overwritten those functions . But these functions are not called when a touch is detected . This function is called when an TextField is present and touches inside the textfields are detected . But why it is not working in WebView .

I found that to make the touchesBegan and touchesEnded functions work , I need to make the object an first responder . I used

print(myWebView.canBecomeFirstResponder) // Return True
myWebView.becomeFirstResponder()
print(myWebView.isFirstResponder) // Return false

I dont know how to make webview an firstResponder and also is there any other ways to detect presses/ Touches while in WKWebView . Can Anyone help me? And Thank you In Advance

Upvotes: 4

Views: 588

Answers (0)

Related Questions