【问题标题】:Objective-C : Issue faced while editing multiple row simultaneously in table viewObjective-C:在表格视图中同时编辑多行时面临的问题
【发布时间】:2015-11-25 11:03:44
【问题描述】:

我正在做聊天应用程序。我对所有主要功能所做的一些事情。现在我对多选行有疑问并对其进行编辑。我在以下两件事上有问题:

1.如果我尝试编辑聊天表视图,单元格会向右移动。我的聊天消息被部分隐藏了。

2. 如果我选择那个圆形按钮,我的单元格上会出现一些颜色。那个颜色隐藏了我的视图颜色。我不知道如何清除那种颜色。

请指导我完成以下两件事。

我的输出:

我的代码:

- (IBAction)cellLongPress:(UILongPressGestureRecognizer *)sender 
{

    [_tableView setEditing:YES animated:YES];
}

在 WhatsApp 中,一侧单元格向右移动,另一侧单元格保持不变。怎么做?

如何清除那个删除暗淡的颜色?

请指导我。

【问题讨论】:

    标签: ios objective-c uitableview uitableviewrowaction


    【解决方案1】:

    回答

    1.我们不想缩进哪个单元格,在我们的 tableviewcell 子类中添加以下代码

    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        float indentPoints = self.indentationLevel * self.indentationWidth;
    
        self.contentView.frame = CGRectMake(indentPoints,
                                            self.contentView.frame.origin.y,
                                            self.contentView.frame.size.width - indentPoints,
                                            self.contentView.frame.size.height);
    } 
    

    2.Color 隐藏我的视图颜色

    行索引路径的单元格中

    -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UIView *bgColorView = [[UIView alloc] init];
            bgColorView.backgroundColor = [UIColor whiteColor];
            [_myChatCell setSelectedBackgroundView:bgColorView];
    return _myChatCell;
        }
    

    设置选择

    - (void)setSelected:(BOOL)selected animated:(BOOL)animated
    {
        [super setSelected:selected animated:animated];
    
        if(selected) {
    _message.backgroundColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0];
    } else {
    _message.backgroundColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0];
    }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-09-02
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      • 2021-08-13
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多