Skip to content

Instantly share code, notes, and snippets.

@tetek
Created September 18, 2011 23:29
Show Gist options
  • Select an option

  • Save tetek/1225709 to your computer and use it in GitHub Desktop.

Select an option

Save tetek/1225709 to your computer and use it in GitHub Desktop.
SuggestionMenu
//I've made sugMenu instance variable and initialized it.
sugMenu = [[SuggestionMenu alloc] initWithSortedArray:array];
//make sure you are implementing UITextFieldDelegate protocol
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[sugMenu suggestForText:@"" inField:textField];
}
//easy as that...
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSString *rightText = [NSString stringWithFormat:@"%@%@",textField.text,string];
[sugMenu suggestForText:rightText inField:textField];
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment