I know that in order to be able to automatically fill a text field with a SMS code, I should set its textContentType
to .oneTimeCode
.
However, I am actually working on a screen with 4 text fields, added programmatically:
(0..<4).forEach { i in
let textField = UITextField()
textField.tag = i
textField.keyboardType = .numberPad
}
The idea is that each text field should contain a digit of the code (which is a 4-digit one). I didn't even set their textContentType
, but when I get the SMS code, and select it, it perfectly fills them but I have no idea why. The only thing I realized is that setting the tag of each UITextField
helps iOS knowing which text field corresponds to which digit of the code.
I can't find any information however of why and how this works.
Thank you for your help
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…