iOS7的UITableView编辑模式内容重叠问题

4

1
请查看:https://dev59.com/xnfZa4cB1Zd3GeqPR3jn#19117382 - Bhavin
3个回答

0

可能你正在cellForRowAtIndexPath(代理方法)中为单元格设置setBackgroundImage。不要在这里设置。请在以下位置设置您的图像:

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { cell.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"cellList.png"]]; }

0
- (void)layoutSubviews
{
 [super layoutSubviews];



self.contentView.frame = CGRectMake(0,
                                    self.contentView.frame.origin.y,
                                    self.contentView.frame.size.width,
                                    self.contentView.frame.size.height);



if ((self.editing
    && (_state & UITableViewCellStateShowingDeleteConfirmationMask))){
    float indentPoints = self.indentationLevel * self.indentationWidth;
    self.contentView.frame = CGRectMake(50,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints - 30,
                                        self.contentView.frame.size.height);
 }
}

0

我实际上使用了这个完全实现来使一切看起来很好:

- (void)layoutSubviews
{
[super layoutSubviews];

self.contentView.frame = CGRectMake(0,
                                    self.contentView.frame.origin.y,
                                    self.contentView.frame.size.width,
                                    self.contentView.frame.size.height);

if ((self.editing
    && ((_state & UITableViewCellStateShowingEditControlMask)
        && !(_state & UITableViewCellStateShowingDeleteConfirmationMask))) ||
    ((_state & UITableViewCellStateShowingEditControlMask)
     ))
{
    float indentPoints = self.indentationLevel * self.indentationWidth;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.frame = CGRectMake(50,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints,
                                        self.contentView.frame.size.height);
}


if ((self.editing
    && (_state & UITableViewCellStateShowingDeleteConfirmationMask)))
{
    float indentPoints = self.indentationLevel * self.indentationWidth;
    self.contentView.frame = CGRectMake(50,
                                        self.contentView.frame.origin.y,
                                        self.contentView.frame.size.width - indentPoints - 30,
                                        self.contentView.frame.size.height);
}
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接