iOS 11 & 12 & 13 - Swift 4.2 & 5 (Updated):
if #available(iOS 12, *) {
// iOS 12 & 13: Not the best solution, but it works.
passwordTextField.textContentType = .oneTimeCode
} else {
// iOS 11: Disables the autofill accessory view.
// For more information see the explanation below.
emailTextField.textContentType = .init(rawValue: "")
passwordTextField.textContentType = .init(rawValue: "")
}
iOS 11 explanation:
Make sure you setup all of your UITextField
objects like this.
If you have for example an UITextField
object where the user must enter his email address and another one where the user must enter his password assign UITextContentType("")
to both of their textContentType
property. Otherwise it will not work and the autoFill accessory view will still be shown.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…