简体   繁体   English

我可以在BarButton上设置UITableViewCellAccessoryCheckmark吗?

[英]Can i set the UITableViewCellAccessoryCheckmark on BarButton?

我想在触摸Bar按钮时UITableViewCellAccessoryCheckmark tableView的所有单元格吗?

You need to set the cell accessory types in the method which you have given in the barbutton declaration. 您需要使用在barbutton声明中指定的方法来设置单元格附件类型。

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; 使用布尔变量isButtonClick;

and attach a action on barButton click says click; 然后在barButton上附加一个动作。

so in click 所以在点击

-(void)click
{
  isButtonClick=YES;
  [yourTable reloadData];
}

now in cellforRowAtIndexPath 现在在cellforRowAtIndexPath中

put condition 放置条件

{
  //your code

  if(isButtonClick)
  {
     [yourTable setAccessoryType:UITableViewCellAccessoryCheckmark];
  }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM