Password autofill is not working in swift
Try naming your text fields serially txt1 txt2 txt3 txt4 tt5 txt6
override func viewDidLoad() {
super.viewDidLoad()
txt1.becomeFirstResponder()
}
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if ((textField.text?.count)! < 1 ) && (string.count > 0) {
if textField == txt1 {
txt2.becomeFirstResponder()
}
if textField == txt2 {
txt3.becomeFirstResponder()
}
if textField == txt3 {
txt4.becomeFirstResponder()
}
if textField == txt4 {
txt5.becomeFirstResponder()
}
if textField == txt5 {
txt6.becomeFirstResponder()
}
if textField == txt6{
txt6.becomeFirstResponder()
}
textField.text = string
return false
} else if ((textField.text?.count)! >= 1) && (string.count == 0) {
if textField == txt2 {
txt1.becomeFirstResponder()
}
if textField == txt3 {
txt2.becomeFirstResponder()
}
if textField == txt4 {
txt3.becomeFirstResponder()
}
if textField == txt5 {
txt4.becomeFirstResponder()
}
if textField == txt6 {
txt5.becomeFirstResponder()
}
if textField == txt1{
txt6.resignFirstResponder()
}
textField.text = ""
return false
} else if (textField.text?.count)! >= 1 {
textField.text = string
return false
}
return true
}
Happy Coding
Why does the Apple-generated strong password autofill have no text?
It was because on my UITextField .clearsOnBeginEditing
was set to true. Whenever the text input became first responder it would clear the existing text, including the Apple generated strong password.
Not sure how to have .clearsOnBeginEditing
and use a Apple generated password though.
Is it possible to modify the AutoFill string before showing in textfield?
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool
where replacementString
is your answer
Related Topics
Swiftui Foreach Index Out of Range Error When Removing Row
Facebook Sdk - iOS - Fail to Share Url (Error 102)
Xcode5:The App References Non-Public Selectors in Payload/<Appname>.App/<Appname>: Setattribution:
How to Create Scrollable Table in Skspritekit
Module Compiled with Swift 5.0.1 Cannot Be Imported by the Swift 5.1 Compiler
Swift Switch Pattern Matching with Arrays
Displaying Youtube Video Ads with Youtube Iframe
How to Decode/Convert a Base64 String to Nsdata
Mkannotationview and Tap Detection
How to Launch My Settings Bundle from My Application
How to Hide "Back to Safari" from Status Bar in iOS9
Parsing JSON Using the New Swift 3 and Alamofire
Ciimage Display Mtkview VS Glkview Performance
How to Use Store and Use an Nsmutableattributedstring in Nsuserdefaults
Apple Watchkit Simulator Issue: Sperrorinvalidbundlenogizmobinarymessage