Reputation:
I need to hide the keyboard as soon as a page starts loading. I've tried all commonly suggested approaches discussed e.g. here
Following approaches have no effect on the keyboard
[webView endEditing:YES];
[webView stringByEvaluatingJavaScriptFromString:@"document.activeElement.blur();"];
[webView stringByEvaluatingJavaScriptFromString:@"window.blur();"];
I invoke them in -webView:shouldStartLoadWithRequest:navigationType:
What am I doing wrong? Any suggestions?
Upvotes: 2
Views: 3142
Reputation: 41
Thanks for your answer. i write this methods
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[webView endEditing:YES];
}
works for me
Upvotes: 4
Reputation:
The problem was that UIViewController
's returned YES
here for UIModalPresentationFormSheet
.
- (BOOL)disablesAutomaticKeyboardDismissal {
return NO;
}
Have a look at that answer.
Upvotes: 1
Reputation: 1103
try
webView.delegate = self;
and inside the -webViewDidFinishLoad:
delegate method
[webView resignFirstResponder];
Upvotes: 0