ios - i need help in "auto-complete for google places using text-field (objective c) -
i new in ios app development need in "auto-complete google places using text-field (objective c)"step step process better understand please me ,thanks in advance.
you should try google developers site.
you can use method :
- (void)placeautocomplete { gmsautocompletefilter *filter = [[gmsautocompletefilter alloc] init]; filter.type = kgmsplacesautocompletetypefiltercity; [_placesclient autocompletequery:@"sydney oper" //this should textfield text bounds:nil filter:filter callback:^(nsarray *results, nserror *error) { if (error != nil) { nslog(@"autocomplete error %@", [error localizeddescription]); return; } (gmsautocompleteprediction* result in results) { nslog(@"result '%@' placeid %@", result.attributedfulltext.string, result.placeid); } }]; }
more info @ : https://developers.google.com/places/ios-api/autocomplete
install sdk : https://developers.google.com/places/ios-api/start
if want implement autocomplete text field try this:
- (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { autocompletetableview.hidden = no; nsstring *substring = [nsstring stringwithstring:textfield.text]; substring = [substring stringbyreplacingcharactersinrange:range withstring:string]; [self searchautocompleteentrieswithsubstring:substring]; return yes; } - (void)searchautocompleteentrieswithsubstring:(nsstring *)substring { // put starts substring autocompleteurls array // items in array show in table view [autocompleteurls removeallobjects]; for(nsstring *curstring in pasturls) { nsrange substringrange = [curstring rangeofstring:substring]; if (substringrange.location == 0) { [autocompleteurls addobject:curstring]; } } [autocompletetableview reloaddata]; // table view show data }
for autocomplete turotial : http://www.raywenderlich.com/336/auto-complete-tutorial-for-ios-how-to-auto-complete-with-custom-values
Comments
Post a Comment