您的位置:首页 > 其它

cell 的自带的系统方法

2016-05-30 11:41 330 查看
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{

// 开始的时候 tableView 的 cell 的selected 为0 当选中一个的时候 之前被选中的 cell 的selected 设置为0, 新选中的 cell 的selected设置为1;
     [ super setSelected:selected animated:animated];

// - 例如下边的例子

1.设置 cell 的 textLabel 的 textColor(选中时候是红色的,非选中时候是灰色的)

self.textLabel.textColor = selected?[UIColor redColor] : [UIColor grayColor];

2. 设置 cell 中的某个控件的隐藏和显示(在选中 cell 时候显示,在非选中的状态 隐藏)

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

    [super setSelected:selected animated:animated];

    self.selectedIndicator.hidden = !selected;

}

// - 设置 cell 的 accessoryView

cell.accessoryView = [UIView alloc]init];

// - 返回 tableview 当前选中的 index

 NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: