Code:
-(IBAction)searchInfo: (id)sender
{
NSString *query = [googleBar.text stringByReplacingOccurrencesOfString:@" " withString:@"+"];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://www.google.co.uk/search?q=%@" , query]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
[textField resignFirstResponder];
NSString *javascriptString = @"document.getElementsByClassName('g')[0].getElementsByTagName('a')[0].click()";
[webView stringByEvaluatingJavaScriptFromString: javascriptString];
}
So basically my 'Searchinfo' button searches whatever the users inputs into the textfield on Google and then displays the first search result. When the user is editing the textfield using the pop up keyboard, I've noticed that the keyboard's search function dosen't do the same thing as the 'Searchinfo' button. Here is my code for the keyboard;
Code:
-(IBAction) returnKeyButton : (id) sender {
[self searchInfo:sender];
[self resignFirstResponder];
}
I have wired everything but I'm not sure why when I resign the keyboard using its search function it doesn't do the same as my button above, this being it taking the users input in the textfield and searching it onto Google and displaying the first search result. Thanks in advance
Last edited by a moderator: