すべてのセルにチェックボックスボタン付きのUITableViewを使用しています。ユーザーがそのセルまたはボタンをタップすると、そのボタンの画像が「選択された」画像に変更されなければなりません。しかし、私が任意のセルやボタンをタップすると、イメージは変化しません。UItableviewcellボタンの画像を変更できません
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell : categoryCell = tableView.dequeueReusableCellWithIdentifier("categoryCell") as! categoryCell
let dic : NSDictionary = categoryitem.objectAtIndex(indexPath.row) as! NSDictionary
cell.category_name.text = dic.valueForKey("category_name") as? String
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return categoryitem.count
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let cell : categoryCell = tableView.dequeueReusableCellWithIdentifier("categoryCell") as! categoryCell
cell.category_button.setImage(UIImage(named: "check_checkbox"), forState: UIControlState.Normal)
let dic : NSDictionary = categoryitem.objectAtIndex(indexPath.row) as! NSDictionary
print(dic.valueForKey("category_id") as! String)
}
categoryCellにimageViewのIBOutletを作成しましたか? –
しかし、私はuibuttonの画像を変更したい。だから私はuibuttonのiboutletを@SandeepBhandariを作成する –
申し訳ありませんがUIButtonを意味した:D –