开发者

Can i set the UITableViewCellAccessoryCheckmark on BarButton?

开发者 https://www.devze.com 2023-01-30 01:55 出处:网络
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

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];
  }

}
0

精彩评论

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

关注公众号