我想在 UITextField
中的上方屏幕中显示相同的自动填充电子邮件功能请建议
答案 0 :(得分:1)
执行以下操作, 1)存储电子邮件 2)当用户开始在textField中键入文本时,搜索存储的值并在UITableView中显示值
您应该使用以下UITextField委托
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
答案 1 :(得分:0)
KingOfBliss所说的是正确的方法。无论如何,我会为你提供一些代码的逻辑。 试试tis代码
- (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
}