0

单击单元格时,我的 TableView 没有将单元格着色为蓝色。InterfaceBuild 有

Selection: Single Selection
Show Selection on Touch : YES

当我点击表格时,我的表格视图控制器中的代码就会运行

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // code
}

编辑

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    NSString *item = (NSString *)[songList objectAtIndex:indexPath.row];
    cell.textLabel.text = item;
    return cell;
}
4

1 回答 1

0

意识到我的问题是我的 cellForRowIndexPath 函数中的以下行

cell.selectionStyle = UITableViewCellSelectionStyleNone;
于 2012-05-21T00:25:28.660 回答