Knowing the complete changed string in textField:shouldChangeCharactersInRange:replacementString:

前端 未结 3 1533
执念已碎
执念已碎 2021-02-02 08:25

I just asked a question about how to monitor changes to a UITextField and received this response :

- (BOOL)textField:(UITextField *)textField should         


        
3条回答
  •  梦谈多话
    2021-02-02 08:35

    -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
    {
        NSString * searchStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
    
    //    [textField2 setText:[textField1.text stringByReplacingCharactersInRange:range withString:string]];
        NSLog(@"%@",searchStr);
        return YES;
    }
    

提交回复
热议问题