删除iPhone上的确认问题

时间:2011-04-09 16:40:58

标签: iphone

enter image description here

我在背景中添加了浅白/灰色,以查看“删除确认”开启时会发生什么。我的问题是,当屏幕上的删除按钮动画时,它不会重新定位我的单元格的内容,所以我有这个奇怪的重叠问题。有人可以帮帮我吗?我必须为此制作自己的动画等吗?谢谢。


编辑添加代码:(我已删除了自动调整功能,因为我无法使其工作..)

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *LogCellId = @"LogCellId";
    UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:LogCellId];

    UILabel *lblSummary;

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:LogCellId] autorelease];   
        lblSummary = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 10.0, 260.0, 30.0)] autorelease];
        lblSummary.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
        lblSummary.tag = SUMMARY_TAG;
        lblSummary.lineBreakMode = UILineBreakModeTailTruncation;
        lblSummary.opaque = YES;
        lblSummary.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0];
        [cell.contentView addSubview:lblSummary];

        cell.contentView.backgroundColor = [UIColor colorWithRed:240.0/255.0 green:240.0/255.0 blue:240.0/255.0 alpha:1.0];
    } else {
        lblSummary = (UILabel *)[cell viewWithTag:SUMMARY_TAG];
    }

    lblSummary.text = [self.logList objectAtIndex:[indexPath row]];

    return cell;
}

3 个答案:

答案 0 :(得分:2)

您很可能已将控件添加到单元格视图本身。不要这样做但是将你的控件添加到UITableViewCell.contentView - 这将确保在切换到编辑模式时你的单元格得到正确的动画。

在看到更新的问题后添加

还要确保您的公正控件设置为autoresizingMask = UIViewAutoresizingFlexibleWidth;

答案 1 :(得分:0)

取决于你是如何做到细胞的。但是autoresizeMask属性可能会有所帮助;)

答案 2 :(得分:0)

“UITableViewCell对象的内容视图是单元格显示内容的默认超级视图。如果要通过简单添加其他视图来自定义单元格,则应将它们添加到内容视图中,以便将它们定位适当的单元格进入和退出编辑模式。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/instp/UITableViewCell/contentView

相关问题