【问题标题】:iPhone SDK - Highlight the selected cell in TableViewiPhone SDK - 突出显示 TableView 中的选定单元格
【发布时间】:2011-06-10 06:24:43
【问题描述】:

我在 tableView 中有一个 customTableViewCell。我选择使用时突出显示单元格,

cell.selectionStyle = UITableViewCellSelectionStyleBlue;

但是,tableView 如下图所示。

它隐藏了 customCell 中的标签和文本。我只想简单地突出显示单元格而不隐藏背景图像和标签。我不知道我在哪里犯了错误,无论是在代码中还是在 IB 中。 .

【问题讨论】:

  • 您自定义了您的 Tableview 吗?
  • 您是如何将子视图添加到单元格的?

标签: iphone uitableview custom-cell


【解决方案1】:
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.Your_imageView.highlightedImage = [UIImage imageNamed:@"Your_image_Name.png"];

这样就可以了

【讨论】:

  • 为此您需要使用 CustomTableViewCell
【解决方案2】:

嘿,我认为您需要将 customCell 中的标签和文本添加到 cell.contentview。如需参考,请参阅 Apple 开发者文档。
http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7

【讨论】:

    【解决方案3】:
    [_tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
    

    将其放入以查看 Will Appear 及其对我的作品,

    NSIndexPath *selectedIndexPath;
    

    也把它放到.h文件中

    【讨论】:

      【解决方案4】:

      试试这个

      UIView *viewSelected = [[[UIView alloc] init] autorelease];
          viewSelected.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"cell_highlighted.PNG"]];
          cell.selectedBackgroundView = viewSelected;
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多