As of now I would like to opt out of the new option iOS 11 gives, that is to suggest passwords in the app. When I run the app on iOS 11 I get the autofill option on top of t
in response to @Gal Shahar Answer.
iOS 12 recognise password textFields by isSecureTextEntry
property and not just by textContentType
property.
Way Around to bypass Auto-fill Suggestion.
isSecureTextEntry
property to false.self.passwordTextField.secureTextEntry = NO;
isSecureTextEntry
property.- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (textField == self.passwordTextField && !self.passwordTextField.secureTextEntry) {
self.passwordTextField.secureTextEntry = YES;
}
return YES;
}
NOTE: -
Do NOT Use shouldBeginEditing
UITextField delegate method it Will Still show Auto-filling Suggestion.
Do NOT Use textFieldDidChange
UITextField delegate method it Will Auto-delete the first charachter as the it Will happen after the first charachter is displayed. And 'secureTextEntry' will empty the field.
Autofill is by default enabled for users. iOS saves all passwords in the keychain and make them available in keyboard in your apps. UITextView
and UITextField
automatically considered for AutoFill password. you can disable by specifying a content type that is neither username nor password but if the content type info already stored in keychain it will show in the quick bar. so better to assign empty UITextContentType
type and it will not show quickbar.
Example:
if #available(iOS 10.0, *) {
self.textField.textContentType = UITextContentType("")
} else {
// Fallback on earlier versions
}