【问题标题】:Grouped UITableView with custom cell in Editing Mode在编辑模式下使用自定义单元格分组 UITableView
【发布时间】:2013-03-29 12:37:52
【问题描述】:

我在 UITable 视图中有问题。我正在使用这样的分组样式的 UITableView 和自定义单元格视图

我的问题是在编辑我的表格视图时,它的显示如下

但我需要在编辑这样的表格视图时隐藏缩略图

我在编辑表格视图[cell.imageviews setHidden:YES] 时尝试过,但它不起作用请任何人帮助我,如果问题已经在 Stack-overflow 中,请给我参考链接或任何其他建议?

** 更新**

这是我的 cellForRowAtIndexPath 代码

   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CustomCellidentifier = @"IListCell";
IListCell *cell = (IListCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellidentifier];
if(cell == nil) {
    
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"IListCell" owner:self options:nil];
    cell = [nib objectAtIndex:0];
        }

  if (self.tableview.isEditing) {
    [cell.photoImageView setHidden:YES];
    }

cell.titleTextField.text=[NSString stringWithFormat:@"%@",[artAlbumList objectAtIndex:indexPath.row]];

return cell;
 }

IListCell 是 UITableViewCelll 的子类,使用 XIB 文件创建的自定义单元这是我的 xib 文件

【问题讨论】:

  • 以该方法发布您的代码。
  • 邮政编码:IListCell

标签: iphone uitableview


【解决方案1】:

用断点测试你的代码
setEditing:editing设置断点

- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
   if(editing == YES){
       photoImageView.hidden = YES
   }
   else
   { 
     photoImageView.hidden = NO; 
   }
}

【讨论】:

    【解决方案2】:

    看起来缩略图实际上不在表格视图单元格内。请记住,您不能创建 UITableViewCell 的任何直接子视图;所有子视图必须是 UITableViewCell 的contentView 的子视图。

    在编辑时自动隐藏图像的最简单方法可能是覆盖自定义单元格类的setEditing:animated:。请务必致电super!根据第一个 (BOOL) 参数隐藏或显示图像。

    【讨论】:

    • 那我该怎么做才能隐藏那张图片?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 2014-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多