我有必須調用檢查手機號碼範圍和其他格式的方法。但是這種方法不會被調用:(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 –