Created
June 6, 2012 10:54
-
-
Save tetek/2881266 to your computer and use it in GitHub Desktop.
SuggestionList - how to
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //In your ViewController define a property with SuggestionsList instance | |
| //in .h | |
| @property(retain)SuggestionsList *suggList; | |
| //in .m | |
| @synthesize suggList = _suggList; | |
| //initialize it with array of strings that contains suggestions you want to present | |
| NSArray *array = [NSArray arrayWithObjects:@"Berlin",@"Warsaw",@"Wroclaw",@"Barcelona",nil]; | |
| self.suggList = [[[SuggestionsList alloc] initWithArray:array] autorelease]; | |
| //implement UITextFieldDelegate in you view controller and implement this method | |
| - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; | |
| //This method is called every time users type something in text field, so we need to update our suggestions here. Make it look like this: | |
| - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{ | |
| [_suggList showSuggestionsFor:textField shouldChangeCharactersInRange:range replacementString:string]; | |
| return YES; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment