AutoFill issue on iOS for getting phone number

Viewed 311

Autofill suggestion fails to populate textfield when tapped on keyboard. Here's what I'm making in my code:

textField.keyboardType = .phonePad
textField.textContentType = .telephoneNumber

But when function

func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool

is called it just returns empty replacementString string.

Device ios version 14.7

EDIT: I found out that if i dont specify/delegate

    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool

function everything works perfectly. Still confused why.

1 Answers

try after set content type to otp

textField.textContentType = .oneTimeCode
Related