後の初期のセルに添付滞在ではないが、リロードがトリガされるたびに、新たに追加されたセルが変更された画像の代わりに、古いものを持っています。これは私のcellForRowAtです:ボタンは、私が押された後の画像を変更するカスタムセル内のボタンを持ってリロード
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Sender", for: indexPath) as! Sender
cell.clearCellData()
cell.message.text = self.items[indexPath.row].content
cell.name.text = self.items[indexPath.row].name
cell.from = self.items[indexPath.row].fromID
return cell
}
ボタンのアウトレットとアクションは次のようにボタン電池の両方である:
@IBAction func downVoted(_ sender: Any) {
if(self.downVote.image(for: .normal) == #imageLiteral(resourceName: "DownGray")){
self.downVote.setImage(#imageLiteral(resourceName: "DownOn"), for: .normal)
}else{
self.downVote.setImage(#imageLiteral(resourceName: "DownGray"), for: .normal)
}
}
新しい行が追加されるまで、それは正常に動作します。私は、ボタンタグをセルタグと同じように設定しようとしましたが、それは助けになりませんでした。誰かがこれに対する修正を知っていますか?
ありがとうございます。
を行うことを忘れないでください、と'cellForRowAt'に適切な画像をセットします。簡単な例として、この質問の私の答えを見てください:https://stackoverflow.com/questions/44393575/checkbox-uitableview-with-different-sections/44398444#44398444 – DonMag