Search code examples
iosuiwebviewwkwebviewwkwebviewconfiguration

WKWebView autocomplete suggestions in UITextField


I am using a WKWebview to display web page and have a UITextField where the user can enter the URL they wish to navigate to (in-app browser of sorts). As the user is typing, I would like to display a list of possibilities (i.e. popular sites). Are there any Apple (or 3rd party) APIs I could use to fetch a list of popular sites based on a substring?

Edit: I need to use a WKWebView as opposed to the new Safari View Controller because I want to be able to inject custom javascript (which is not allowed in the former)


Solution

  • Use this URL for auto complete

    http://suggestqueries.google.com/complete/search?client=chrome&q=YOURQUERY

    Like

    search?client=chrome&q=apple

    Use TableView For Showing the suggestions.

    - (IBAction)act_search:(id)sender {
        if([_txt_search.text length] > 2)
        {
    
            Code Here ...
    
            [_tableview reloadData];
    
    
        }
        else
        {
            jsonarr = nil;
            [_tableview reloadData];
        }
    
    
    }