uitableview消除点击时候的灰色效果

方案1:
在- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath加 cell.selectionStyle = UITableViewCellSelectionStyleNone;
注意:该方案是彻底干掉灰色背景

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.imageView.image = [UIImage imageNamed:self.meImgsArr[indexPath.section][indexPath.row]];
    cell.textLabel.text = self.meDataSource[indexPath.section][indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

方案二:修改- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
方法中加[tableView deselectRowAtIndexPath:indexPath animated:NO];
注意:该方案是抬手以后没有灰色背景

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 版权声明:未经本人允许,禁止转载. 1. TableView初始化 1.UITableView有两种风格:UITa...
    萧雪痕阅读 2,999评论 2 10
  • { 24、Sqlite数据库 1、存储大数据量,增删改查,常见管理系统:Oracle、MSSQLServer、DB...
    CYC666阅读 1,064评论 0 1
  • //设置行高 (CGFloat)tableView:(UITableView *)tableView height...
    俊月阅读 1,403评论 0 1
  • NSArray*array1_=@[@"张铁林",@"张国立",@"张国荣",@"张艺谋",@"张惠妹"]; NS...
    Sherry宇阅读 471评论 0 2
  • UITableView 基本使用方法 1. 首先,Controller需要实现两个 delegate ,分别是U...
    yymyb阅读 363评论 0 0

友情链接更多精彩内容