IOS -- UITableView里面点击一个cell改变其他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
默认选中第五行,设置点击不显示灰
- (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;
}
出自
https://www.cnblogs.com/qiyiyifan/p/7641989.html
iOS,Tableview点击显示灰色背景,松手不显示灰色背景,(上面cell里面设置另外一种方式)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
转载于:https://www.jianshu.com/p/1d059c374ffa