美文网首页
ios tableviewCell点击切换显示的图片

ios tableviewCell点击切换显示的图片

作者: Tomboy_Anan | 来源:发表于2018-03-22 10:50 被阅读33次
未命名.gif

思路是: 循环 获取到所有cell 的下标. 将图片或按钮的状态全部置未 NO 或 隐藏, 再获取当前点击的 cell. 将图片或按钮 置为 yes

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    for (int i = 0; i < 2; i++) {
        NSIndexPath *index = [NSIndexPath indexPathForRow:i inSection:1];
        OJBSunriseSunsetTableViewCell *cell = [tableView cellForRowAtIndexPath:index];
        cell.selectStatusImageView.hidden = YES;
    }
    OJBSunriseSunsetTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.selectStatusImageView.hidden = NO;
    
    if (self.selectCityIndex) {
        self.selectCityIndex(indexPath);
    }
}

相关文章

网友评论

      本文标题:ios tableviewCell点击切换显示的图片

      本文链接:https://www.haomeiwen.com/subject/xuuduxtx.html