In objective-c I can just say the following.
[self.promoTextField setKeyboardType:UIKeyboardTypeEmailAddress];
I tried googling it but just ge
Sometimes give UITextField extension to add one method, you can use like that "textField.chooseKeyboardType(keyboardType:.pad)", perhaps this is not a good way, but useful.
public extension UITextField {
func chooseKeyboardType(_ keyboardType:UIKeyboardType) {
switch keyboardType {
case .emailAddress:
self.keyboardType = .emailAddress
case .twitter:
self.keyboardType = .twitter
case .numberPad:
self.keyboardType = .numberPad
case .numbersAndPunctuation:
self.keyboardType = .numbersAndPunctuation
case .asciiCapable:
self.keyboardType = .asciiCapable
case .URL:
self.keyboardType = .URL
case .decimalPad:
self.keyboardType = .decimalPad
case .namePhonePad:
self.keyboardType = .namePhonePad
default:
self.keyboardType = .default
}
}
}