1 Replies - 2342 Views - Last Post: 15 October 2013 - 11:42 AM

#1 2468  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-October 13

The 'search' fuction on my textfield keyboard isn't workin

Posted 15 October 2013 - 11:36 AM

 -(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;
-(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

Is This A Good Question/Topic? 0
  • +

Replies To: The 'search' fuction on my textfield keyboard isn't workin

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10486
  • View blog
  • Posts: 38,858
  • Joined: 27-December 08

Re: The 'search' fuction on my textfield keyboard isn't workin

Posted 15 October 2013 - 11:42 AM

Please avoid duplicate posting. You have an existing thread in our Objective-C forum on this topic.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1