IOS - UITableView click inside a cell to change the settings of other cell
#import "DepositTableViewCell.h"
@implementation DepositTableViewCell
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
if (isSelected) {
_taskName.text= @"YES";
}
else{
_taskName.text= @"NO";
}
[super setSelected:selected animated:animated];
}
@end
The fifth line is selected by default, set the click does not display gray
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
DepositTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DepositTableViewCell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;//设置点击不显示灰色背景
cell.taskUIimage.image=[UIImage imageNamed:@"chongwu1019.jpg"];
//默认选中第五行
if (indexPath.row == 4) {
[tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
return cell;
}
From
https://www.cnblogs.com/qiyiyifan/p/7641989.html
iOS, Tableview click on a gray background, do not let go display gray background, (which is provided above the cell in another way)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
Reproduced in: https: //www.jianshu.com/p/1d059c374ffa