0
我已經實現了多個UITextField's
,並且想要在達到最大限制時切換到下一個文本字段。我已經實現以下的委託方法,但由於某種原因導致崩潰,而不是切換到達到極限時,下一個文本字段...在多個uitextfields之間切換
任何幫助將不勝感激......
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSLog(@"%s", __FUNCTION__);
NSString *totalText = [textField.text stringByAppendingString:string];
NSLog(@"Length : %d", [totalText length]);
switch (textField.tag) {
case FirstTextFieldTag: {
if ([totalText length] > MaxLentgthTextField1) {
[self.textField1 resignFirstResponder];
[self.textField2 becomeFirstResponder];
}
break;
}
case SecondTextFieldTag: {
if ([totalText length] > MaxLentgthTextField2) {
[self.textField2 resignFirstResponder];
[self.textField3 becomeFirstResponder];
}
break;
}
case ThirdTextFieldTag: {
if ([totalText length] > MaxLentgthTextField3) {
[self.textField3 resignFirstResponder];
[self.textField4 becomeFirstResponder];
}
break;
}
case FourthTextFieldTag: {
if ([totalText length] > MaxLentgthTextField4) {
[self.textField4 resignFirstResponder];
[self.textField5 becomeFirstResponder];
}
break;
}
case FifthTextFieldTag: {
if ([totalText length] > MaxLentgthTextField5) {
[self.textField5 resignFirstResponder];
return NO;
}
break;
}
default:
break;
}
return YES;
}
的長度,你能否告訴日誌崩潰? –
什麼是你的錯誤? – manujmv