iOS 11 adds smart quotes when typing. In macOS we can disable smart quotes on a NSTextView
by setting:
textView.automaticQuoteSubstitutionEnabled = NO;
Neither UITextField
or UITextView
seem to have this property or the enabledTextCheckingTypes property. How can smart quotes be disabled on iOS 11?
With iOS 11, Apple introduced Smart Punctuation. By default, this feature automatically converts ambidextrous straight quotes to curly quotes, in addition to converting two hyphens (–) to an em dash (—). In the case of quotes, it also replaces the straight apostrophes and quotes with language-specific glyphs.
Smart quotes and other features such as smart dashes are controlled via the UITextInputTraits
Protocol which is adopted by both UITextField
and UITextView
.
Specifically, the smartQuotesType
property can be set to one of .default
, .yes
or .no
. At this time there is no further documentation on these values, but .yes
and .no
are self-explanatory. My guess on .default
is that the system will use properties such as textContentType
and isSecureTextEntry
to determine the appropriate behaviour.
For example a text content type of email, password or URL would probably disable smart quotes by default while job title may default to enabled. I imagine secure text entry fields would also have smarts disabled by default.
Setting an appropriate text content type for your input views can significantly improve the user experience and is highly recommended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With