我想发送服务电话以了解该引脚是否正确。我有4个文本字段。如果输入第4个文本字段,则服务调用必须自动进行。这意味着所有文本字段都应填写。如果用户更改1或2或3或4,则服务调用必须采用这种方式。我知道我们必须写入textField:shouldChangeCharactersInRange
。但我不知道在哪里写。
请帮帮我。这是我的代码:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *acceptedInput = [NSCharacterSet characterSetWithCharactersInString:ACCEPTABLE_CHARECTERS];
if (textField == self.textFied1&&([[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 0))
{
int length = (int)[textField.text length];
if (length==1)
{
[self.textField2 becomeFirstResponder];
if(range.length == 0)
{
[self.textField2 becomeFirstResponder];
return NO;
}
if([self.textFied1.text length]==1)
{
self.textFied1.text=@"";
[self.textFied1 becomeFirstResponder];
return NO;
}
}
if (([[self.textField4 text] length] > 0)&& ([[self.textField2 text] length] > 0)&& ([[self.textField3 text] length] > 0)&& ([[self.textFied1 text] length] > 0)){
[self connected1];//this step is not executing
}
}
else if (textField == self.textField2&&([[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 0))
{
int length = (int)[textField.text length];
if (length==1)
{
if(range.length == 0)
{
[self.textField3 becomeFirstResponder];
return NO;
}
if([self.textField2.text length]==1)
{
self.textField2.text=@"";
[self.textFied1 becomeFirstResponder];
return NO;
}
}
if (([[self.textField4 text] length] > 0)&& ([[self.textFied1 text] length] > 0)&& ([[self.textField3 text] length] > 0)&&([[self.textField2 text] length] > 0)){
[self connected1];//this step is not executing
}
}
else if (textField == self.textField3&&([[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 0))
{
int length = (int)[self.textField3.text length];
if (length==1)
{
if(range.length == 0)
{
[self.textField4 becomeFirstResponder];
return NO;
}
if([self.textField3.text length]==1)
{
self.textField3.text=@"";
[self.textField2 becomeFirstResponder];
return NO;
}
}
if (([[self.textField4 text] length] > 0)&& ([[self.textField2 text] length] > 0)&& ([[self.textFied1 text] length] > 0)&& ([[self.textField3 text] length] > 0)){
[self connected1];//this step is not executing
}
}
else if (textField == self.textField4&&([[string componentsSeparatedByCharactersInSet:acceptedInput] count] > 0))
{
int length = (int)[textField.text length];
if (length==1)
{
if(range.length == 0)
return NO;
if([self.textField4.text length]==1)
{
self.textField4.text=@"";
[self.textField3 becomeFirstResponder];
return NO;
}
}
// here my service code
if (([[self.textFied1 text] length] > 0)&& ([[self.textField2 text] length] > 0)&& ([[self.textField3 text] length] > 0)&&([[self.textField4 text] length] > 0))
{
[self connected1];//this step is not executing
}
}
return YES;
}
答案 0 :(得分:0)
这种情况正在发生,因为在NSString *content = [textField.text stringByAppendingString:string];
中你无法直接获取字符串。
首先将用户的输入文本设为:
content
然后将所有条件与> webdriver-manager update --versions.chrome 2.24
> webdriver-manager start --versions.chrome 2.24
匹配。