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];
  • 相关阅读:
    while循环
    No.四
    No. three
    第二章吧
    第二次写博客
    我人生的第一个程序,相当于哥伦布发现新大路。
    orale命令6 rman备份
    oracle 命令4 热备份
    oracle命令3 冷备份
    oracle命令2 和一致性关闭、非一致性关闭
  • 原文地址:https://www.cnblogs.com/sgdkg/p/2784601.html
Copyright © 2011-2022 走看看