Hello everyone I'm trying to embed images for each textfield ... When I go to insert the text into the first textfield, the image also has an impact on the second textfield. I would that images visualizzassero each textfield that the user selects and not directly to all ... Where am I doing wrong?
Thanks to all
-(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;
}
All textFields trigger this method. You should use the argument 'textField' in an if-statement to determine the identity of the sender.
if( [textField isEqual: FF_NomeCognomeTexfield] == YES){
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With