i wa开发者_运维技巧nt UITableViewCellAccessoryCheckmark the all cells of tableView while am touching the Bar Button ?
You need to set the cell accessory types in the method which you have given in the barbutton declaration.
Check this code. Follow like that
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(showChecked)];
- (void)showChecked{
isChecked = YES;
[tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
return cell;
}
use a bool variable isButtonClick;
and attach a action on barButton click says click;
so in click
-(void)click
{
isButtonClick=YES;
[yourTable reloadData];
}
now in cellforRowAtIndexPath
put condition
{
//your code
if(isButtonClick)
{
[yourTable setAccessoryType:UITableViewCellAccessoryCheckmark];
}
}
精彩评论