             //            }
         }
     }
-    
+
     /**
      *  显示允许输入的最大文字长度，默认为 Int.max，也即不限制长度。
      */

                let swiftRange = Range(nsRange, in: textField.text!)
                let allowedText = textField.text!.qmui_substringAvoidBreakingUpCharacterSequencesWithRange(range: swiftRange!, lessValue: true, countingNonASCIICharacterAsTwo: shouldCountingNonASCIICharacterAsTwo)
                textField.text = allowedText
                
                if originalDelegate?.responds(to: #selector(QMUITextFieldDelegate.textField(_:didPreventTextChangeInRange:replacementString:))) ?? false && textField.qmui_selectedRange() != nil {
                    originalDelegate!.textField!(textField, didPreventTextChangeInRange: textField.qmui_selectedRange()!, replacementString: nil)
                }
            }
        }
    }
    
    func fireTextDidChangeEvent(forTextField textField: QMUITextField) {
        textField .sendActions(for: .editingChanged)
        NotificationCenter.default.post(name: NSNotification.Name.UITextFieldTextDidChange, object: textField)
    }
    
    private func lengthWithString(_ string: String) -> UInt {
        return UInt(shouldCountingNonASCIICharacterAsTwo ? string.qmui_lengthWhenCountingNonASCIICharacterAsTwo : string.length)
    }
    
    // MARK: QMUITextFieldDelegate
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        
        if let textField = textField as? QMUITextField {
            if textField.maximumTextLength < UInt.max {
                // 如果是中文输入法正在输入拼音的过程中（markedTextRange 不为 nil），是不应该限制字数的（例如输入“huang”这5个字符，其实只是为了输入“黄”这一个字符），所以在 shouldChange 这里不会限制，而是放在 didChange 那里限制。
                
                let isDeleting = range.length > 0 && string.length <= 0
                if isDeleting || (textField.markedTextRange != nil) {
                    if textField.originalDelegate?.responds(to: #function) ?? false {


        return true
    }
}
