iphone - 选择时 Xcode UITableView 行未突出显示

我的 iphone 应用程序上有一个工作 TableView ,我正在使用 navigationController 实现第二个 View 。

但是当我尝试在初始 View 中选择一个单元格时,它没有响应,即没有蓝色突出显示,没有选择。

任何人都可以建议我可能遗漏了什么,或者当用户点击时实际选择单元格的负责人是什么?

好的,谢谢你的建议 - 还是不行。这是我的代码:

- (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]autorelease];

        [cell setSelectionStyle: UITableViewCellSelectionStyleBlue]; 

        UIView *selectionView = [[[UIView alloc] init] autorelease];
        selectionView.backgroundColor =[UIColor redColor];
        cell.selectedBackgroundView = selectionView;
    }

    // format text

    cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12];
    cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];

        return cell;
}


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

    //NSUInteger row = indexPath.row;
    //[DetailView selectRowAtIndexPath:indexPath animated:YES];

    //UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath.row];
    //[cell setSelectionStyle: UITableViewCellSelectionStyleBlue]; 


    DetailView *detailView = [[DetailView alloc] initWithNibName:@"DetailView" bundle:nil];
    [self.navigationController pushViewController:detailView animated:YES];
    [DetailView release];

}

最佳答案

可能是您在 cellForRowatIndexPath::

中完成了这行代码
 cell.selectionStyle = UITableViewCellSelectionStyleNone;

如果是,则将其替换为以下之一:

 cell.selectionStyle = UITableViewCellSelectionStyleGray;

 cell.selectionStyle = UITableViewCellSelectionStyleBlue;

https://stackoverflow.com/questions/9975037/

相关文章:

fortran - 大型阵列导致 OpenMP 崩溃

visual-studio - 将 tinyxml2 与 Visual Studio、Visual

c# - 使用 "new"初始化的 Fixed(){} 中的多个指针不起作用

php - 使用 sha256WithRSAEncryption 签名需要什么版本的 OpenSSL

jsf - 如何为 h :graphicImage Primefaces 添加操作

wordpress - 使用帖子 ID 查询帖子

php - 获取最近过去的星期六(上星期六)

python - 从嵌套函数中的封闭范围访问变量

C++ 问题 - getline 跳过第一个输入

r - 使用已经汇总的数据在 ggplot2 上生成条形图