ios tableviewCell点击切换显示的图片

2018-03-22  本文已影响33人  Tomboy_Anan
未命名.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);
    }
}

上一篇 下一篇

猜你喜欢

热点阅读