i am trying to find out a solution when the return key of UIWebview is clicked ! i tried the following links but it's not working !
UIWebView, customize "return" key
How to detect keyboard enter key?
i want to do some offset work when user is typing on the UIWebview and return key is pressed !
Here is the code i am using !
- (void)viewDidLoad
{
[super viewDidLoad];
NSString* plainContent = @"Edit here.....";
NSString* htmlContentString = [NSString stringWithFormat:
@"<html>"
"<body>"
"<div id=\"content\" contenteditable=\"true\" style=\"font-family: Arial\">"
"%@"
"</div>"
"</body></html>", plainContent];
[_webview loadHTMLString:htmlContentString baseURL:nil];
}
- (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{
NSString *requestString = [[request URL] absoluteString];
NSArray *components = [requestString componentsSeparatedByString:@":"];
NSString *theTask = (NSString *)[components objectAtIndex:0];
if([[[request URL] absoluteString] rangeOfString:@"enterClicked"].location!=NSNotFound) // When "enterClicked" found
{
NSLog(@"enterClicked !");
//Do your desired work
return NO;
}
if([theTask isEqualToString:@"returnkeypressed"]){
NSLog(@"theTask");
[aWebView endEditing:YES];
return NO;
}
return YES;
}
at the end of the webpage may let the webview to scroll. – Sabbath Dec 02 '13 at 06:23