I am new to swift I can used reminder check box in login page working fine,
- when Reminder checkBox select show the credential in log text Field it's working
- when Reminder checkBox unselect credential is clear from the log text Field working
but when logout after if i can click reminder checkbox to unselect the reminder checkBox it's not selecting first time when I click Double its selecting,
this is the code
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let checkviewapper = UserDefaults.standard
let logindata = UserDefaults.standard
let data = checkviewapper.integer(forKey:"checked")
print("data values is ",data)
if(data == 1)
{
RmdButton.setImage( UIImage(named:"check.png"), for: .normal)
emailText.text = logindata.string(forKey: "emaild_default")
passwordText.text = logindata.string(forKey: "password_default")
}
else
{
emailText.text = ""
passwordText.text = ""
RmdButton.setImage( UIImage(named:"uncheck.jpeg"), for: .normal)
}
}
@IBAction func checkBox(_ sender: UIButton) {
let defautls = UserDefaults.standard
defautls.removeObject(forKey:"checked")
defautls.synchronize()
if unchecked {
let defautls = UserDefaults.standard
defautls.set(unchecked, forKey: "checked")
defautls.synchronize()
if let myLoadedString = defautls.string(forKey: "checked") {
}
sender.setImage( UIImage(named:"check.png"), for: .normal)
print("checked inside")
unchecked = false
}
else {
sender.setImage( UIImage(named:"uncheck.jpeg"), for: .normal)
print("uncheckinside")
unchecked = true
}
}
where I did mistake, how to set the reminder CheckBox uncheck at First Time pls help me.....!
Aucun commentaire:
Enregistrer un commentaire