私は非常に困惑しています。私のcellForRowAtIndexPathメソッドでカスタムUITableViewCellでUIButtonにアクセスする
、私はUIButtonのタイトルを設定しようとしています:
が機能していない:
react
は私のUITableViewCellのサブクラスのサブビューでUIButton、ある
cell?.react?.setTitle("\(currentObject.likes)", forState: UIControlState.Normal)
を。
UIButtonのタイトルを更新できないようです。私はそれが私のUITableViewCellのサブクラスでUITapGestureRecognizer経由で変更することが分かってきた唯一の方法、
ワーキング:
func reaction(button : UIButton) {
if button.imageView?.image == UIImage(named: "ic_favorite.png") {
button.setImage(UIImage(named: "ic_favorite_border.png"), forState: UIControlState.Normal)
} else {
button.setImage(UIImage(named: "ic_favorite.png"), forState: UIControlState.Normal)
}
}
は 'react'であるあなたのテーブルのセルにそのボタンのタグを与え、このようにしてみてください?なぜあなたの反応はどこで私のカスタムセルのサブクラスであるのですか? – Tj3n
あなたは反応のアクションを宣言した –