Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 - disable smart quotes

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?

like image 352
Kyle Avatar asked Jul 05 '17 17:07

Kyle


People also ask

What are smart quotes iOS?

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.


1 Answers

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.

like image 181
Paulw11 Avatar answered Oct 03 '22 05:10

Paulw11