i m 形成一种形式。 因此,当用户点击提交纽顿时,即检查是否填满了所有自成文的领域:
-(BOOL)checkUITextField{
BOOL flag = YES;
if(cognome.text.length==0){
flag=NO;
cognome.backgroundColor=[UIColor redColor];
cognome.text=@"CAMPO OBBLIGATORIO";
}else if(indirizzo.text.length==0){
flag=NO;
indirizzo.backgroundColor=[UIColor redColor];
indirizzo.text=@"CAMPO OBBLIGATORIO";
}else if(citta.text.length==0){
flag=NO;
citta.backgroundColor=[UIColor redColor];
citta.text=@"CAMPO OBBLIGATORIO";
}
}
Now, if user click on one of the uitextfield with background red and string "CAMPO OBBLIGATORIO", i want to clear text and set back color to white.
i try using uitextfielddelegate
and implementing textFieldShouldBeginEditing
checking this:
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if([textField.text isEqualToString:@"CAMPO OBBLIGATORIO"]){
textField.text=@"";
textField.backgroundColor=[UIColor whiteColor];
}
}
没有发生。
这样一来,就试图增加一种交易,并用西比语将它添加到每个建筑区,但是没有发生任何事情。 可以做些什么?