Reputation: 11
Hi, Iam new to iPhone apps. I have a problem with tableview. Here I want to add checkmark when I click on the cell, it's working fine. But whenever I click on another cell then the before cell should not show the checkmark.Thanx in advance.
Upvotes: 0
Views: 90
Reputation: 458
A cell's accessory type is set by the UITableViewDataSource protocol. This code snippet toggles the cell's accessory type between 'none' and 'checkmark':
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"checkableTableViewCell";
OEListTableViewCell *cell = (OEListTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[OEListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.accessoryType = (cell.accessoryType == UITableViewCellAccessoryCheckmark) ? UITableViewCellAccessoryNone : UITableViewCellAccessoryCheckmark;
}
Upvotes: 0
Reputation: 150755
I wrote an example project for this a while ago ExclusiveCheckedTableView
Upvotes: 1