Friday, June 21, 2024
HomeIOS Developmentios - Stop Username Autofill in Incorrect UITextField with Biometric Authentication

ios – Stop Username Autofill in Incorrect UITextField with Biometric Authentication

I am encountering a difficulty with the autofill habits in considered one of my iOS purposes. On an motion affirmation display screen, customers can enter a cause within the first textual content discipline and their account password within the second textual content discipline for validation objective. Nevertheless, when customers use biometric authentication (Contact ID/Face ID) to autofill the password, the username from the keychain is mistakenly being entered into the explanation textual content discipline (over-rides the already crammed cause).

Right here’s the setup:

  • The primary textual content discipline (reasonTextField) is for customers to enter the explanation.
  • The second textual content discipline (passwordTextField) is for the account password.

I’ve tried the next options with out success:

  1. Setting textContentType to .none for the reasonTextField.
  2. Making certain passwordTextField has textContentType set to .password.
  3. Utilizing distinct accessibility identifiers for each textual content fields.

Here is a simplified model of my code:

import UIKit

class ActionConfirmationViewController: UIViewController {
    @IBOutlet weak var reasonTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!
    override func viewDidLoad() {
    func configureTextFields() {
        reasonTextField.textContentType = .none
        reasonTextField.accessibilityIdentifier = "reasonTextField"
        passwordTextField.textContentType = .password
        passwordTextField.accessibilityIdentifier = "passwordTextField"
        passwordTextField.isSecureTextEntry = true

Regardless of these measures, the difficulty persists. Has anybody skilled an identical drawback or have any strategies on easy methods to forestall the username from being autofilled into the explanation textual content discipline? Any assist could be tremendously appreciated!



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments