ableview中,如何加载自定义cell? 如何改变选中某一行的颜色(或不显示颜色)

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *CellIdentifier = @"Cell";

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

NSArray *array = [[NSBundle mainBundle]loadNibNamed:@"SearchOptionCell" owner:self options:nil];

cell = [array objectAtIndex:0];

[cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    }

    return cell;

}

上面的代码中,

[cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 不显示选中颜色

改变其他style,可以用:

[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];

[cell setSelectionStyle:UITableViewCellSelectionStyleGray];

原文地址:https://www.cnblogs.com/changxs/p/3440554.html