我有必须调用检查手机号码范围和其他格式的方法。但是这种方法不会被调用:(shouldChangeCharactersInRange没有被调用。?
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)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;
}
检查您的文本字段是否包含委托集? – jokerday
[cell.txtMobile setDelegate:<#(id _Nullable)#>]; 我应该在<<#(id _Nullable)#>中输入什么表达式 @deyanlai –