Add auto-completion to a UITextField
YONAutoComplete
Add auto-completion to a UITextField.
Simplest auto-complete:
just create a YONAutoComplete
object and assign it as the delegate of a UITextField
:
YONAutoComplete *autoComplete = [YONAutoComplete new];
textField.delegate = autoComplete;
The user can either choose from the list of completions, or type a new value that will be added to the list automatically.
Customiztion
You can use pre-assembled completions list from a text file:
autoComplete.completionsFileName = @"SomeFileName";
Or set the completions list programmatically:
autoComplete.completions = @[@"First Item", @"Second Item"];
To prevent user-typed values from being added to the completions list:
autoComplete.freezeCompletionsFile = YES;
Limit number of completions shown:
autoComplete.maxCompletions = 7;
Installation
CocoaPods:
pod 'YONAutoComplete'