Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting UITextField's textContentType to creditCardNumber overrides keyboardType setting?

Tags:

ios

swift

I am setting my text field's content type and keyboard type as follows:

numberTextField.textContentType = .creditCardNumber
numberTextField.keyboardType = .numberPad

However, the resulting keyboard is the default QWERTY keyboard. The number pad keyboard only shows up when I remove the textContentType setting.

This happens both when I set these attributes programmatically and in the interface builder.

Is this a bug or am I missing something?

like image 343
SpillYerLungs Avatar asked Nov 27 '19 18:11

SpillYerLungs


2 Answers

The keyboard type for a creditCardNumber field changes if you set returnKeyType.

like image 192
Vadim Yelagin Avatar answered Nov 14 '22 23:11

Vadim Yelagin


Is that what you're talking about? If so, either the two or just the one, the numeric keypad always opens.

enter image description here

like image 1
Barış Arslan Avatar answered Nov 15 '22 01:11

Barış Arslan