所以我的项目中有分段控件 我想要的是如果我在分段控件上单击否 -它将检查验证,如果所有验证都已完成,则按钮将更改颜色,并且我的按钮已启用
如果我在按钮上单击是 -它将显示另一个文本字段,并且我的按钮将停用,直到所有验证都已完成
但是我的问题是,如果在完成所有验证后我单击“否”,然后再次单击“是”,则我的下一个按钮仍然处于活动状态,除非我单击文本字段并单击“完成”按钮。
这是我的代码
func textFieldDidEndEditing(_ textField: UITextField) {
if(alamatIdentitasTextField.text != "" && provinsiIdentitasTextField.text != "" && kotaIdentitasTextField.text != "" && kelurahanIdentitasTextField.text != "" && kecamatanIdentitasTextField.text != "" && kodePosIdentitasTextField.text != "" ){
if alamatDomisiliSegmentedControl.selectedSegmentIndex == 0 {
if(alamatDomisiliTextField.text != "" && provinsiDomisiliTextField.text != "" && kotaDomisiliTextField.text != "" && kelurahanDomisiliTextField.text != "" && kecamatanDomisiliLabel.text != "" && kodePosDomisiliTextField.text != "" ){
nextButton.isEnabled = true
nextButton.backgroundColor = #colorLiteral(red: 1, green: 0.4431372549, blue: 0.003921568627, alpha: 1)
}else {
nextButton.isEnabled = false
nextButton.backgroundColor = #colorLiteral(red: 0.662745098, green: 0.662745098, blue: 0.662745098, alpha: 1)
}
}else if alamatDomisiliSegmentedControl.selectedSegmentIndex == 1 {
nextButton.isEnabled = true
nextButton.backgroundColor = #colorLiteral(red: 1, green: 0.4431372549, blue: 0.003921568627, alpha: 1)
}else {
nextButton.isEnabled = false
nextButton.backgroundColor = #colorLiteral(red: 0.662745098, green: 0.662745098, blue: 0.662745098, alpha: 1)
}
}else {
nextButton.isEnabled = false
nextButton.backgroundColor = #colorLiteral(red: 0.662745098, green: 0.662745098, blue: 0.662745098, alpha: 1)
}
}