I am using UITextView
and when user enter three consecutive dots ..., it gets replaced as ellipses … (unicode \u2026
). How to avoid this? I need the actual string which user entered; not the auto corrected string.
Note: I have tried setting autoCorrectionType
to .no
, but no luck.
let textView = UITextView()
textView.delegate = self
textView.translatesAutoresizingMaskIntoConstraints = false
textView.font = UIFont.preferredFont(forTextStyle: .caption1)
Here is the delegate method,
func textViewDidChange(_ textView: UITextView) {
print("User entered string: \(textView.string)")
}
CodePudding user response:
From Apple's docs:
Instance Property
smartDashesType
The configuration state for smart dashes.
Discussion
Use this property to configure whether UIKit converts two hyphens into an en-dash and three hyphens into an em-dash automatically. The default value of this property is UITextSmartDashesType.default, which selectively enables smart dashes based on the keyboard type.
Curiously, it makes no mention of converting three consecutive periods into an ellipses, but it IS part of that functionality.
So, using:
let textView = UITextView()
textView.smartDashesType = .no
will disable it -- but it will also disable the en-dash and em-dash conversion.