[英]Enable button only after text fields are entered
Apple 开始拒绝我的应用程序(经过多年的批准)——我有 2 个文本字段用于姓氏、名字的几个字符,然后按 Go。他们声称——如果你只按 Go,我无法重现应用程序崩溃的情况——当我运行它,它尝试发送请求,但由于错误“无名称 - 请重新输入”而将其踢回。 任何。 为了安抚 Apple,我将我的文本字段输入方法编辑到现在(见下文)- 但仍然无法正常工作。 请指教。
// Text Field methods
-(void)textFieldDidBeginEditing:(UITextField *)textField {
UIFont* boldFont = [UIFont fontWithName:@"Helvetica-Bold" size: 24];
if (textField == _lastName) {
[_lastName becomeFirstResponder];
[_lastName setFont:boldFont];
_lastName.autocorrectionType = UITextAutocorrectionTypeNo;;
_lastName.autocapitalizationType = UITextAutocapitalizationTypeNone;
_lastName.text = @"";
NSLog(@"user editing last...");
// Enable button once fields have values
if ([_lastName.text isEqual: @""] && [_firstName.text isEqual: @""])
{
_fwdButton.enabled = YES;
}
}
else {
[_firstName becomeFirstResponder];
[_firstName setFont:boldFont];
_firstName.autocorrectionType = UITextAutocorrectionTypeNo;;
_firstName.autocapitalizationType = UITextAutocapitalizationTypeNone;
_firstName.text = @"";
NSLog(@"user editing first");
// Enable button once fields have values
if ([_lastName.text isEqual: @""] && [_firstName.text isEqual: @""])
{
_fwdButton.enabled = YES;
}
}
}
我能够添加类似于 [https://stackoverflow.com/questions/2859821/disable-button-until-text-fields-have-been-entered][1] 的代码
处理这种情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.