Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
391 views
in Technique[技术] by (71.8m points)

ios - SMS OTP verification with UITextField without setting .oneTimeCode?

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...