Email autocomplete feature in UITextField

My image

I want to implement the same email autofill feature as shown above on screen in UITextField

Please suggest

+3
source share
2 answers

Do the following: 1) store emails 2) When the user begins to enter text in a text field, the search is stored and displays the values ​​in a UITableView

You should use the following delegate UITextField

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
+1
source

What kingOfBliss said is the right way. Anyway, I will give you some code logic. Try the tis code

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{

for(NSString *particularEmail in arrayContainsAllEmailAddress)
    {
            NSString *firstLetter = @"";
            NSInteger stringlen=[string length];
            if(particularEmail.length >= stringlen)
            {
                firstLetter = [particularEmail substringToIndex:stringlen];
            }
            if(firstLetter.length > 0)
            {
                if([string.uppercaseString isEqualToString:firstLetter.uppercaseString])
                    {
                        [tableArray addObject:particularEmail];
                        //tableArray is the array which u will load into the tableview. This contains the emails that matches your search name.
                    }       
            }
    }
    // Add your tableArray into UITableView
}
0

Source: https://habr.com/ru/post/1778096/


All Articles