Increase the main tableview row height according to the custom cell

前端 未结 7 713
名媛妹妹
名媛妹妹 2021-01-03 07:32

I am having an app in which I have a Tableview and on that tableview\'s each row I am dynamically creating a custom tableview cell.

Below is the cod

7条回答
  •  无人及你
    2021-01-03 07:39

    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
    NSString *str = [arrComments objectAtIndex:indexPath.row];
    UIFont *font = [UIFont fontWithName:@"Helvetica" size:14];
    CGRect new = [str boundingRectWithSize:CGSizeMake(280, 999) options:NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName: font} context:nil];
    CGSize size= new.size;
    NSLog(@"%f",size.height);
    if (size.height<20)
    
    {
        size.height=20;
        //m= size.height;
    
    }
    
    NSLog(@"%f",size.height);
    
    return size.height +  30;
    
    
    }
    

提交回复
热议问题