开发者

How can we put a checkbox in uitableviewcell

I created list 开发者_StackOverflow社区of todos. Now I want to put the checkbox for each one cell. When I mark it as checked, it can be marked and then we select delete button if we want, which is also in the same cell at right side and deleted, but I am not able to perform action like this.

Can anyone please help me?


@Chakradhar not a big issue you can do it very easily with or without using custom images.

In your didSelectRowAtIndexPath delegate try to check and set the UITableViewCellAccessory as per your condition.

This is the way in which there is no need to use extra images and you can checked for you particular selected cell:

if (//here you check)
{   // item needed - display checkmark
    cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{   // not needed no checkmark
    cell.accessoryType = UITableViewCellAccessoryNone;
}

Take this shopping tutorial and see didSelectRowAtIndexPath delegate method see how they had used the condition.

Edited as per your last comment: For custom accessory view look for Implement a Custom Accessory View For UITableView in iPhone

Good Luck!


Use this

cell.accessoryType = UITableViewCellAccessoryCheckmark;


You can actually add custom button with an unchecked image on your cell. On button action method you can change the image to checked & handle rest of the things you want to handle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜