uitableviewcell选中打勾

单元格选中后,打勾。再选其他,之前的勾取消,新的打勾。

代码如下(不加代码高亮了吧):

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSIndexPath *oldIndex = [tableView indexPathForSelectedRow];

[tableView cellForRowAtIndexPath:oldIndex].accessoryType = UITableViewCellAccessoryNone;

[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark;

return indexPath;

}

时间: 2024-08-08 18:12:11

uitableviewcell选中打勾的相关文章

UItableViewCell选中时的颜色及tableviewCell的select和deselect

今天做项目美工和我说cell点击后再跳回当前页面cell的默认点击状态应该取消,后来在网上查到,其实比较简单,有两种实现方法,代码如下 方法一: 在页面将要出现的时候对tableview执行deselect操作 - (void)viewWillAppear:(BOOL)animated{ [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES]; } 看上面的英文也应

iOS uitableViewCell 选中 push后返回 取消选中状态

首先我有一个UITableViewController,其中每个UITableViewCell点击后都会push另一个 ViewController,每次点击Cell的时候,Cell都会被选中,当从push的ViewController返回的时候选中的Cell便会 自动取消选中.后来由于某些原因我把这个UITableViewController改成了UIViewController,之后就产生了一个问题:每 次返回到TableView的时候,之前选中的Cell不能自动取消选中,经过查找得知: U

设置UITableViewCell 选中时的背景颜色

自定义Cell如图 一个View上面放了四个Label 分别连线到.m文件中 @property (weak, nonatomic) IBOutlet UILabel *nameLabel; @property (weak, nonatomic) IBOutlet UILabel *positionLabel; @property (weak, nonatomic) IBOutlet UILabel *paperLabel; @property (weak, nonatomic) IBOutle

UITableViewCell 选中的状态小技巧

- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; //cell 没被选中时 隐藏这个 _leftImageView self.leftImageView.hidden = !selected; //选中text变红 不然变灰色 self.textLabel.textColor = selected ? [UIColor redCo

UITableViewCell选中后子View背景色被Clear

在TableView中,当cell 处于Hightlighted(高亮)或者Selected(选中)状态下,Cell上的子控件的背景颜色会被 Clear. 解决方法:(4种) 1. 直接设置子控件的 layer的背景颜色, layer不会受影响 2.重写方法,执行 -(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{ [super setHighlighted:highlighted animated:animated]

UITableViewcell选中后怎么去掉背景灰色

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } 在这个函数里写上cell.selectionStyle

Datagridview 中的checkbox 选中或勾选状态失效

1.问题描述,先选中第一行,再取消选择,然后点击部门全选,第一行没有打钩,状态是不选中的状态. 2.分析代码 先选中第一行,单元格的单击事件中 改变选中状态为1,第一行取消选择,单元格的单击事件中 改变选中状态为0 private void dgvDept_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex == 1) { if (thi

UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 [cpp] viewplaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = UITableViewCellSelectionStyleBlue; //灰色 cell.selectionStyle = UITableViewCellSelectionStyleGray; 2.自定义颜色和背景设置 改变UITableViewCe

iOS开发UITableViewCell的选中时的颜色设置

1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = UITableViewCellSelectionStyleBlue; //灰色 cell.selectionStyle = UITableViewCellSelectionStyleGray; 2.自定义颜色和背景设置 改变UITableViewCell选中时背景色: UIColor *color