zoukankan      html  css  js  c++  java
  • cell 自适应高度

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
            cell.textLabel.numberOfLines = 0;
            cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:17.0];
    }
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    NSString *cellText = @"Go get some text for your cell.";
    UIFont *cellFont = [UIFont fontWithName:@"Helvetica" size:17.0];
    CGSize constraintSize = CGSizeMake(280.0f, MAXFLOAT);
    CGSize labelSize = [cellText sizeWithFont:cellFont constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];

    return labelSize.height + 20;
    }
    ---------------------------
    other mehod the solve this problem
    UILabel* label = [[UILabel alloc] initWithFrame:cell.frame];
    label.numberOfLines = <...an appriate number of lines...>
    label.text = <...your text...>
    [label sizeToFit];
    [cell addSubview:label];
    [label release];
  • 相关阅读:
    前端安全问题
    windows下nginx的安装及使用方法入门
    windows下安装nginx
    获取div的高度
    HAOI2015 简要题解
    JLOI2016 简要题解
    JLOI2015 DAY2 简要题解
    JLOI2015 DAY1 简要题解
    SCOI2016 Day2 简要题解
    CS Academy Sliding Product Sum(组合数)
  • 原文地址:https://www.cnblogs.com/sgdkg/p/2784601.html
Copyright © 2011-2022 走看看