Monday, May 20, 2024
HomeiOS Developmentios - Forestall Username Autofill in Incorrect UITextField with Biometric Authentication

ios – Forestall Username Autofill in Incorrect UITextField with Biometric Authentication


I am encountering a difficulty with the autofill conduct in one among my iOS functions. On an motion affirmation display, customers can enter a purpose within the first textual content area and their account password within the second textual content area for validation objective. Nonetheless, when customers use biometric authentication (Contact ID/Face ID) to autofill the password, the username from the keychain is mistakenly being entered into the rationale textual content area (over-rides the already stuffed purpose).

Right here’s the setup:

  • The primary textual content area (reasonTextField) is for customers to enter the rationale.
  • The second textual content area (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() {
        tremendous.viewDidLoad()
        
        configureTextFields()
    }
    
    func configureTextFields() {
        reasonTextField.textContentType = .none
        reasonTextField.accessibilityIdentifier = "reasonTextField"
        
        passwordTextField.textContentType = .password
        passwordTextField.accessibilityIdentifier = "passwordTextField"
        passwordTextField.isSecureTextEntry = true
    }
}

Regardless of these measures, the problem persists. Has anybody skilled an identical drawback or have any solutions on the right way to forestall the username from being autofilled into the rationale textual content area? Any assist can be drastically appreciated!



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments