Prevent indentation of UITableViewCell (contentView) while editing

前端 未结 9 811
心在旅途
心在旅途 2020-12-05 02:38

Is it possible to keep the contentView.frame always the same, regardless of tableView.editing? I already tried to override layoutSubviews

9条回答
  •  难免孤独
    2020-12-05 03:04

    You can always get a tableviewcell with an indexpath. Using that tableviewcell reuseidentifier, You can avoid the tableview cell content size to be resized or not. I had a requirement to implement the similar kind of functionality to avoid resizing of seperate cells. PFB the code.

    -(BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath{
    
    BOOL shouldIndentWhileEditingRow = NO;
    
    UITableViewCell *lTableViewCell = [tableView cellForRowAtIndexPath:indexPath];
    
    /*Change the position of the target rect based on Sending messages or Receiving messages*/
    if ([lTableViewCell.reuseIdentifier isEqualToString:@"SendingChatCellIdentifier"]) {
    
        shouldIndentWhileEditingRow = NO;
    
    }else if ([lTableViewCell.reuseIdentifier isEqualToString:@"ReceivingChatCellIdentifier"]){
    
        shouldIndentWhileEditingRow = YES;
    }
    
    return shouldIndentWhileEditingRow;
    }
    

提交回复
热议问题