繁体   English   中英

我可以在BarButton上设置UITableViewCellAccessoryCheckmark吗?

[英]Can i set the UITableViewCellAccessoryCheckmark on BarButton?

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

您需要使用在barbutton声明中指定的方法来设置单元格附件类型。

检查此代码。 那样跟随

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

使用布尔变量isButtonClick;

然后在barButton上附加一个动作。

所以在点击

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

现在在cellforRowAtIndexPath中

放置条件

{
  //your code

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

}

暂无
暂无

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

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