swift - How can I disable auto-correct on an input box? -


i'd disable auto-correct on input box in app. i've found solution objective-c looks this:

    uitextfield* f = [[uitextfield alloc] init];     f.autocorrectiontype = uitextautocorrectiontypeno; 

i've tried implementing this, doesn't work:

    // in viewcontroller     @iboutlet weak var webaddressinput: uitextfield!     // in viewdidload     webaddressinput.autocorrectiontype = uitextautocorrectiontypeno 

how can disable auto-correct on input box in swift?

swift's treatment of enums takes little getting used to. if search on uitextautocorrectiontypeno in docs, leads umbrella type uitextautocorrectiontype.

the swift definition of type

enum uitextautocorrectiontype : int {     case default     case no     case yes } 

in swift use type.value,

uitextautocorrectiontype.no 

your line

webaddressinput.autocorrectiontype = uitextautocorrectiontype.no 

(although, looking @ docs, don't see autocorrectiontype property on uitextfield)


Comments

Popular posts from this blog

smartface.io - Proper way to change color scheme for whole application -

javascript - three.js lot of meshes optimization -

Email notification in google apps script -