-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when insert same character with the patternSymbol, will happen crash! #39
Comments
Will investigate it, can you please share how do you create a formatter, that crashes. |
Here is my code to create formatter. ···
/// SubClass inheritance from TextFieldInputController
class MeetingNumberInputDelegator: TextFieldInputController {
override func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
/// filter space in string
let inputStr = string.replacingOccurrences(of: " ", with: "", options: .literal, range: nil)
return super.textField(textField, shouldChangeCharactersIn: range, replacementString: inputStr)
}
}
···
/// Define in view
var meetingNumberInputController = MeetingNumberInputDelegator()
var meetingNumberFormatter : DefaultTextInputFormatter = {
let formatter = DefaultTextInputFormatter(textPattern: "### #### ########")
return formatter
}()
···
/// Use
inputNoField.delegate = meetingNumberInputController
meetingNumberInputController.formatter = meetingNumberFormatter |
I can suggest you a quick fix, during init of formatter you can pass pattern symbol parameter and set it to some other symbol. Later I will try to fix this crash. |
Fixed at 2.5.2. |
eg: current textfield exist "8123456#",then, if your insert other number,will crash。Console show
Fatal error: String index is out of bounds: file Swift/StringCharacterView.swift, line 60
The text was updated successfully, but these errors were encountered: