by textfield inside a UIWebview , I take it as UITextField as a subview inside a UIWebview right ?
in that s the case you just need to implement the UITextFieldDelegate in your class, specifically this delegate method textFieldShouldReturn , which is called whenever the done button is tapped, so basically you ll have something like this :
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if (textField == correctTextField) {
textField.resignFirstResponder()
}
return true
}
obviously you will need to assign that controller as the textField delegate in the first place
but supposedly it s not a native textfield but rather a html or some kind of a part of the webcontent then what i would do , i would make it invoke a request with a special scheme, for exemple "hideKeyboard" and i would implement uiwebviewdelegate and test for that scheme to hide the keyboard whenever i encouter it, here s an exemple in obj c:
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *URL = [request URL];
NSString *scheme = [URL scheme];
if ([scheme isEqualToString:@"hideKeyboard"]) {
[self.view endEditing:true];
}
}