Ios7 Textfield-确保用户至少填写一个字段
在我的应用程序中注册时,我希望确保用户填写一个字段但对于用户来说,哪个字段应该无关紧要。这就是我遇到的问题。我得到的壁橱是强制用户填写一个特定的文本字段,如下面的代码。我想这不是最好的用户体验:)有人知道该怎么做吗Ios7 Textfield-确保用户至少填写一个字段,ios7,uitextfield,Ios7,Uitextfield,在我的应用程序中注册时,我希望确保用户填写一个字段但对于用户来说,哪个字段应该无关紧要。这就是我遇到的问题。我得到的壁橱是强制用户填写一个特定的文本字段,如下面的代码。我想这不是最好的用户体验:)有人知道该怎么做吗 self.saveButton.delegate = self; - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:
self.saveButton.delegate = self;
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if ([self.RandomTextField.text isEqualToString:@""]) {
self.saveButton.enabled = NO;
} else {
self.saveButton.enabled = YES;
}
return YES;
}
在“注册”按钮的单击事件中
- (IBAction)SignUPBtn:(UIButton *)sender {
if([textfeld_Email.text length]>0)
{
//sign up
}
else
{
if([textfeld_Pswd.text length]>0)
{
//sing up
}
else{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Please enter your email and pass" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
}
谢谢你,伙计。但我只希望用户填写3个字段中的1个,以便能够保存。最重要的是,用户可以选择自己填写的witch字段。你明白我在找什么吗?你有三个文本字段,所以当用户点击并在任意文本字段[textfeld.text length]中写入时,你会发现哪个文本字段是满的还是不满的谢谢你的回答。我如何以最好的方式做到这一点。我真的不明白。。
- (IBAction)SignUPBtn:(UIButton *)sender {
if(txtName.text.length==0 && txtEmail.text.length==0 && txtPass.text.length==0)
{
[[[UIAlertView alloc] initWithTitle:@"" message:@"Please Fill Atleast One Field" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]show];
}
else
{
//Write Your Code here. this else called only if anyone of three textfield is filled up.
}
}