Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

2468

macrumors newbie
Original poster
Oct 11, 2013
2
0
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:

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,567
6,073
Are you sure this code is getting called, and if so, how? If you're not sure it's getting called, you should check if it is or not, either by learning to use the debugger and setting breakpoints, or by inserting some NSLog statements.
 

2468

macrumors newbie
Original poster
Oct 11, 2013
2
0
Are you sure this code is getting called, and if so, how? If you're not sure it's getting called, you should check if it is or not, either by learning to use the debugger and setting breakpoints, or by inserting some NSLog statements.

Thanks i checked but nothing till not getting what i want :(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.