How to create check mark in the table view in iPhone?

Pugalmuni picture Pugalmuni · Dec 6, 2010 · Viewed 7.3k times · Source

I want to create a check mark in the table view. When I tap the particular row, the check mark is visible, so I want to display the check mark when selected at the particular row. Please guide me and give me some links.

Here my code is,

  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

                [self.tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;
          }

I want to display the accessory type, when I click the particular state(selected only one row at a time).

Thanks.

Answer

Jbryson picture Jbryson · Jan 30, 2013

Make sure you delegate is set properly for this controller and that the table view is connected to the delegate on the controller:

tableview.delegate = self;

After that your code should work. I tried your code in my own app and it worked (minus the self.tableview, since my tableview is not a property of the controller.)