【问题标题】:UITableViewCell with UIImageView losing animation (iOS 5 bug?)带有 UIImageView 的 UITableViewCell 失去动画(iOS 5 错误?)
【发布时间】:2011-10-17 01:33:42
【问题描述】:

到目前为止,这对我来说效果很好 - 但在 iOS 5 中,当我在分组 tableview 上的常规 UITableViewCell 上有一个 imageView 并将表格从编辑设置为不编辑时,动画会丢失并且文本和图像视图只是弹回原位而不是滑动。我没有重新加载任何东西——在我想到简单地注释掉我说的那一行之前,我将我的代码剥离到几乎没有解决这个问题

cell.imageView.image = [UIImage imageNamed:@"image.png"];

然后一切正常。这是 iOS 5 中的错误吗?

编辑:到目前为止,我认为这是交付的 tableview 单元格的 UIImageView 的问题。对于自定义单元格和没有 imageView 的 UITableViewCell 来说,设置非编辑动画似乎是可以的。我很想找到一种方法来解决这个问题,这会让事情看起来不专业。

下面是我所说的分组表视图部分的代码,这是 cellforrowatindexPath 的一部分:

static NSString *CellIdentifier = @"ItemDetailDefaultCell";
            UITableViewCell *cell = (UITableViewCell *)[tableView1 dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
                cell.backgroundColor = [[UIApplication sharedDelegate] defaultCellBackgroundColor];

                cell.textLabel.backgroundColor = [UIColor clearColor];
                cell.textLabel.shadowOffset = CGSizeMake(0.0, 1.0);

                cell.detailTextLabel.backgroundColor = [UIColor clearColor];

                cell.detailTextLabel.font = detailTextLabelFont;
                cell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
                cell.detailTextLabel.minimumFontSize = DETAIL_TEXT_LABEL_MINIMUM_FONT_SIZE;

                cell.detailTextLabel.textColor = [[UIApplication sharedDelegate] defaultDetailTextColor];
                cell.detailTextLabel.shadowColor = [[UIApplication sharedDelegate] defaultDetailShadowColor];
                cell.detailTextLabel.shadowOffset = CGSizeMake(0.0, 1.0);
            }
            else {
                UIView* subview;
                while ((subview = [[[cell contentView] subviews] lastObject]) != nil)
                    [subview removeFromSuperview];
                cell.textLabel.text = nil;
                cell.detailTextLabel.text = nil;
            }
            cell.selectionStyle = [[UIApplication sharedDelegate] defaultCellSelectionStyle];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.accessoryView = nil;
            cell.editingAccessoryView = nil;

            cell.autoresizingMask = UIViewAutoresizingFlexibleWidth;
            cell.contentMode = UIViewContentModeLeft;

            cell.textLabel.textColor = [[UIApplication sharedDelegate] defaultMainTextColor];
            cell.textLabel.shadowColor = [[UIApplication sharedDelegate] defaultMainShadowColor];
            cell.textLabel.font = textLabelFont;
            cell.textLabel.adjustsFontSizeToFitWidth = YES;
            cell.textLabel.minimumFontSize = TEXT_LABEL_MINIMUM_FONT_SIZE;

            [(UACellBackgroundView *)cell.backgroundView setHeader:NO];
            if (row < itemsCount) {
                [(UACellBackgroundView *)cell.backgroundView setPosition:UACellBackgroundViewPositionMiddle];
            }
            else {//row == items.count
                if (self.editing) {
                    [(UACellBackgroundView *)cell.backgroundView setPosition:UACellBackgroundViewPositionMiddle];
                }
                else {
                    [(UACellBackgroundView *)cell.backgroundView setPosition:UACellBackgroundViewPositionBottom];
                }
            }
            cell.textLabel.text = item.name;
            cell.imageView.image = [UIImage imageNamed:@"status1.png"];
return cell;

【问题讨论】:

  • 你能提供更多这个类的代码吗,或者创建一个新项目并在其中只测试imageView

标签: uitableview cocoa-touch animation ios5


【解决方案1】:

您是否使用此方法进入编辑模式

[myTable setEditing:NO animated:YES];

另外,如果你正在重新加载数据,那也会取消动画。

【讨论】:

  • 是的,使用那个方法。不重新加载表格视图,因为我知道这会取消动画(请参阅原始问题)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多