How to detect when user used Password AutoFill on a UITextField

前端 未结 7 2161
半阙折子戏
半阙折子戏 2020-12-10 03:26

I\'ve implemented all the app and server changes necessary to support Password Autofill on iOS 11, and it works well. I\'d like it to work a little better.

My usern

相关标签:
7条回答
  • 2020-12-10 04:20

    I found another simple way.. Hope it will help who is looking for it.

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    // Usually string is coming as single character when user hit the keyboard .. 
    // but at AutoFill case it will come as whole string which recieved .. 
    // at this moment you can replace what you currently have by what you have recieved.
    // In below case I'm expecting to recieve 4 digits as OTP code .. you can change it by what you are expecting to recieve.
        if string.count == 4 {
                doWhatEverYouByAutoFillString(text: string)
                return true
            } 
        }
    }
    
    0 讨论(0)
提交回复
热议问题