我有必须调用的方法来检查手机号码范围和其他格式。但是这个方法没有被调用
-(BOOL)textFieldUITextField *)textField shouldChangeCharactersInRangeNSRange)range replacementStringNSString *)string{
ProfileBasicCell *cell=[_tblView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
if (cell.txtMobile.text== textField && string.length>0) {
NSString *newText=[textField.text stringByReplacingCharactersInRange:range withString:string];
if (newText.length<=15) {
if (newText.length==4 || newText.length==8) {
textField.text=[newText stringByAppendingString"-"];
return NO;
}
return YES;
} else {
return NO;
}
}
return YES;
}
Best Answer-推荐答案 strong>
你设置了代理吗?
class yourViewController: UITextFieldDelegate {
}
self.yourTextField.delegate = self;
关于ios - shouldChangeCharactersInRange 没有被调用。?,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/40677054/
|