Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Done key in keyboard in swift-language?

Tags:

xcode

ios

swift

In objective-C I use this code for adding Done key to keyboard

[textField setReturnKeyType:UIReturnKeyDone];

How to set Done key in keyboard in swift-language?

in swift this code gives error 'not have a member named setReturnKeyType'

textField.setReturnKeyType
like image 997
Ivan R Avatar asked Jun 12 '14 08:06

Ivan R


2 Answers

You directly assign the value to the returnKeyType property.

textField.returnKeyType = UIReturnKeyType.Done

In Swift, you access the individual items in the enum with a dot syntax. This can also be shortened further to:

textField.returnKeyType = .Done
like image 125
Mick MacCallum Avatar answered Nov 09 '22 03:11

Mick MacCallum


You can do it like that:

textField.returnKeyType = UIReturnKeyType.Done
like image 23
Prine Avatar answered Nov 09 '22 03:11

Prine