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

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -