【问题标题】:Change an image when UITableViewCell is selected选择 UITableViewCell 时更改图像
【发布时间】:2013-03-11 06:12:11
【问题描述】:

我有一个UITableViewController,我在这些单元格中添加了一个UIImageView。这个UIImageView 在一个自定义的 TableViewCell 中。所以我的问题是当我使用didSelectRowAtIndexPathdelegate 方法选择行时如何更改此图像。我试过了,它在 tableviewcell 上显示图像,但单击此图像后没有改变。如何解决?

这是我的代码 -

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

             MantrasListCell *customCell = [tableView 
             dequeueReusableCellWithIdentifier:CellIdentifier];

               if (customCell == nil) 
               {
                  customCell = [[MantrasListCell 
                  alloc]initWithStyle:UITableViewCellStyleDefault 
                  reuseIdentifier:CellIdentifier];
               }

         customCell.imgView.image = [UIImage imageNamed:@"play.png"];

         return customCell;
      }

   - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
     {
    MantrasListCell *customCell = (MantrasListCell*)[tableView          
                              cellForRowAtIndexPath:indexPath];

    customCell.imgView.image = [UIImage imageNamed:@"pause.png"];        
     }

【问题讨论】:

  • 请解释问题.!!
  • 好....最后你填补了这些点...现在这看起来像一个问题。

标签: iphone uitableview customization


【解决方案1】:

此链接将为您解释。您需要做的就是相应地设置图像,而不是隐藏。

How to check cell is selected in UItableview for image display

【讨论】:

    猜你喜欢
    • 2013-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多