gpt4 book ai didi

validation - 用于验证的 TextField 自定义

转载 作者:行者123 更新时间:2023-12-03 16:24:27 25 4
gpt4 key购买 nike

大家好,我正在尝试为每个文本字段嵌入图像......
当我将文本插入第一个文本字段时,图像也会对第二个文本字段产生影响。我会图像visualizzassero 用户选择的每个文本字段,而不是直接向所有文本字段......我哪里做错了?

谢谢大家

-(BOOL)textFieldShouldEndEditing:(UITextField *)textField   {
NSString *nomecognome = self.FF_NomeCognomeTexfield.text ;
NSString *user = self.FF_UsernameTextField.text ;

if ([nomecognome length] == 0 || [user length] == 0 ){

FF_NomeCognomeTexfield.leftViewMode = UITextFieldViewModeAlways;

UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
imageView.image = [UIImage imageNamed:@"FF_CheckOFF"];
imageView.contentMode = UIViewContentModeScaleAspectFit;
FF_NomeCognomeTexfield.leftView = imageView;

FF_UsernameTextField.leftViewMode = UITextFieldViewModeAlways;
UIImageView* imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
imageView1.image = [UIImage imageNamed:@"FF_CheckOFF"];
imageView1.contentMode = UIViewContentModeScaleAspectFit;
FF_UsernameTextField.leftView = imageView1;
} else {
FF_NomeCognomeTexfield.leftViewMode = UITextFieldViewModeAlways;
UIImageView* imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
imageView.image = [UIImage imageNamed:@"FF_CheckON"];
imageView.contentMode = UIViewContentModeScaleAspectFit;
FF_NomeCognomeTexfield.leftView = imageView;

FF_UsernameTextField.leftViewMode = UITextFieldViewModeAlways;
UIImageView* imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
imageView1.image = [UIImage imageNamed:@"FF_CheckON"];
imageView1.contentMode = UIViewContentModeScaleAspectFit;
FF_UsernameTextField.leftView = imageView1;
}
return YES;
}

最佳答案

所有 textField 都会触发此方法。您应该在 if 语句中使用参数“textField”来确定发件人的身份。

if( [textField isEqual: FF_NomeCognomeTexfield] == YES){
...
}

关于validation - 用于验证的 TextField 自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18947698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com