Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Following link may help you: <a href="http://www.raywenderlich.com/336/how-to-auto-complete-with-custom-values" rel="nofollow">http://www.raywenderlich.com/336/how-to-auto-complete-with-custom-values</a></p> <p>Follow the same flow. To get autocomplete suggestions after comma modify the delegate method as found below.</p> <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { autocompleteTableView.hidden = NO; NSString *names = [NSString stringWithString:textField.text]; NSArray* arr = [names componentsSeparatedByString:@","]; NSString *subString = [arr lastObject]; substring = [substring stringByReplacingCharactersInRange:range withString:string]; [self searchAutocompleteEntriesWithSubstring:substring]; return YES; } </code></pre> <p>Provide a NSMutableArray named 'allNames' which contains all the names you want to display in the suggestion list and use it as the following:</p> <pre><code>- (void)searchAutocompleteEntriesWithSubstring:(NSString *)substring { [autocompleteUrls removeAllObjects]; for(NSString *curString in allNames) { NSRange substringRange = [curString rangeOfString:substring]; if (substringRange.location == 0) { [autocompleteUrls addObject:curString]; } } [autocompleteTableView reloadData]; } </code></pre> <p>When the user clicks the suggestions display the name by appending with previously entered names.</p> <pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // set the textField.text by appending this name to already entered names } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload