How to auto fetch OTP, if we use multiple text fields

后端 未结 4 1356
花落未央
花落未央 2021-01-07 23:52

I know that if we want to auto fetch the OTP(if we use single textfield) we need to use

otpTextField.textContentType = .oneTimeCode

But, If

4条回答
  •  旧时难觅i
    2021-01-08 00:24

    What I do is similar to @Natarajan's answer, but I use UITextFieldDelegate method. On viewDidAppear your first text field should become first responder and be of type oneTimeCode.

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {        
        // Fill your textfields here
    
        return true
    }
    

提交回复
热议问题