Ich verwende DLRadioButton in Tabellenansicht Zellen. Ich habe 30 Zellen in der Tabelle und 4 DLRadioButton jede Zelle. Beispiel wenn ich das erste Optionsfeld in der ersten Zelle ausgewählt habe, 5., 9., 13., 17., 21., 25. und 29. das erste Optionsfeld der Zelle wurde automatisch ausgewählt. Wie repariere ich das?Matrix-Vermessung in der Zelle Tableview auf Swift
DLRadioButton: https://github.com/DavydLiu/DLRadioButton
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ac",for:indexPath) as! AnswerChoicesTableCell
cell.tag = data[indexPath.row]["ac_id"].intValue;
let acID:Int = data[indexPath.row]["ac_id"].intValue;
cell.ACTitle.text = data[indexPath.row]["ac_question"].stringValue
cell.ACButton1.setTitle(data[indexPath.row]["ac_choice_1"].stringValue, for: .normal)
cell.ACButton1.titleLabel?.numberOfLines = 0
cell.ACButton1.titleLabel?.lineBreakMode = .byWordWrapping
cell.ACButton1.acID = acID
if(data[indexPath.row]["ac_choice_1"].stringValue == "-"){
cell.ACButton1.isHidden = true
for constraint in cell.ACButton1.constraints {
if constraint.identifier == "h" {
constraint.constant = 0
}
}
cell.ACButton1.layoutIfNeeded()
}
cell.ACButton2.setTitle(data[indexPath.row]["ac_choice_2"].stringValue, for: .normal)
cell.ACButton2.titleLabel?.numberOfLines = 0
cell.ACButton2.titleLabel?.lineBreakMode = .byWordWrapping
cell.ACButton2.acID = acID
if(data[indexPath.row]["ac_choice_2"].stringValue == "-"){
cell.ACButton2.isHidden = true
for constraint in cell.ACButton2.constraints {
if constraint.identifier == "h" {
constraint.constant = 0
}
}
cell.ACButton2.layoutIfNeeded()
}
cell.ACButton3.setTitle(data[indexPath.row]["ac_choice_3"].stringValue, for: .normal)
cell.ACButton3.titleLabel?.numberOfLines = 0
cell.ACButton3.titleLabel?.lineBreakMode = .byWordWrapping
cell.ACButton3.acID = acID
if(data[indexPath.row]["ac_choice_3"].stringValue == "-"){
cell.ACButton3.isHidden = true
for constraint in cell.ACButton3.constraints {
if constraint.identifier == "h" {
constraint.constant = 0
}
}
cell.ACButton3.layoutIfNeeded()
}
cell.ACButton4.setTitle(data[indexPath.row]["ac_choice_4"].stringValue, for: .normal)
cell.ACButton4.titleLabel?.numberOfLines = 0
cell.ACButton4.titleLabel?.lineBreakMode = .byWordWrapping
cell.ACButton4.acID = acID
if(data[indexPath.row]["ac_choice_4"].stringValue == "-"){
cell.ACButton4.isHidden = true
for constraint in cell.ACButton4.constraints {
if constraint.identifier == "h" {
constraint.constant = 0
}
}
cell.ACButton4.layoutIfNeeded()
}
cell.ACButton4.otherButtons = [cell.ACButton1,cell.ACButton3,cell.ACButton2]
return cell
}
Eher nur ein Objekt mit 4 Möglichkeiten erstellen? – Tj3n