我的tableview看起來像這樣UISwitch是在其他細胞改變狀態時滾動
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! Cell
return cell
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 200
}
而且我tableviewcell看起來像這樣
class Cell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
當我在任何細胞和滾動改變開關狀態。另一個單元的開關週期性地在其他單元的滾動狀態中改變。請幫助
這是因爲電池出隊的。你能否用數據模型更新你的問題? – Baig
這就是問題所在。我創建了測試項目來查看我的數據模型是否會導致此問題。但只有這些代碼,它給我同樣的問題 – cole
請檢查我的更新【答案】(https://stackoverflow.com/a/45857034/1556386) – Baig