【问题标题】:iOS7 UItableview Editing mode content overlap [duplicate]iOS7 UItableview编辑模式内容重叠[重复]
【发布时间】:2013-10-03 09:29:43
【问题描述】:

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

我已经检查了UITableViewCell content overlaps delete button when in editing mode in iOS7 的问题,但对我的情况没有帮助。

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

如果您对此问题有任何想法,请告诉我。

【问题讨论】:

标签: iphone uitableview ios7


【解决方案1】:
- (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);
 }
}

【讨论】:

    【解决方案2】:

    我实际上是使用这个完整的实现来让一切看起来都很好:

    - (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);
    }
    }
    

    【讨论】:

      【解决方案3】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-17
        • 1970-01-01
        相关资源
        最近更新 更多