Snowman
Snowman

Reputation: 32061

Display custom button for all cells in UITableView

I have a UITableView with a custom cell. On the press of a button called Edit, I want a UIButton checkMarkBox to appear on all cells. So initially checkMarkBox is hidden, but when this IBAction method is called for Edit, I want the checkMarkBox to be unhidden. When I do this now, it only unhides the box for the last cell, not all of them. So I need a way to go through every cell in my table view and unhide the check box. I'm thinking some kind of for loop that goes through all the cells will do the trick, but I'm not sure how to get that started.

Upvotes: 0

Views: 89

Answers (1)

Nathanial Woolls
Nathanial Woolls

Reputation: 5291

When the button is pressed, set a BOOL in an instance variable for your class. In cellForRowAtIndexPath, check that BOOL and show or hide the checkMarkBox. In the IBAction for your button, set the BOOL, and then call:

[self.tableView reloadData];

Upvotes: 1

Related Questions