iOS7 UItableview编辑模式内容重叠

时间:2013-10-03 09:29:44

标签: iphone uitableview ios7

当我在iOS 7中进入UITableView的编辑模式时,我的单元格内容与删除按钮重叠。 enter image description here

我已经检查了UITableViewCell content overlaps delete button when in editing mode in iOS7个问题但在我的情况下没有用。

我正在动态地在tableView:cellForRowAtIndexPath方法中创建我的单元格。

如果您对此问题有任何想法,请与我们联系。

3 个答案:

答案 0 :(得分: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);
 }
}

答案 1 :(得分: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);
}
}

答案 2 :(得分:0)

您可能正在cellForRowAtIndexPath(委托方法)中为Cell设置单元格setBackgroundImage。不要在这里设置。将图像设置为:

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