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

前端 未结 3 1528
执念已碎
执念已碎 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:27

    Swift Version

    In Swift We need to cast textField's text to NSString. The following can be useful:

    let newString = (textField.text! as NSString).replacingCharacters(in: range, with: string)
    

提交回复
热议问题