【问题标题】:How Can I Set the Height of a Single UITabelViewCell to a Constant Value?如何将单个 UITabelViewCell 的高度设置为恒定值?
【发布时间】:2010-11-11 14:16:35
【问题描述】:

我在谷歌上搜索这个,但我总是找到非常复杂的解决方案。我有一个带有不可编辑的可滚动 UITextView 的单元格,我只想将该单元格的高度增加到一个恒定值。我该怎么做?实际上我正在使用下一个代码将 UITextView 添加到单元格中。

cell.contentView.bounds = CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height);

UITextView *textView = [[UITextView alloc] initWithFrame:cell.contentView.bounds];
textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
textView.editable = NO;
textView.scrollEnabled = YES;
textView.backgroundColor = [UIColor clearColor];
textView.text = self.description;

[cell.contentView addSubview:textView];
[textView release];

感谢阅读。

【问题讨论】:

    标签: objective-c ios uitableview


    【解决方案1】:

    【讨论】:

    • 感谢 jxpx777。这是我自己的解决方案。 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if ((indexPath.section != SECTION_NUMBER)) { // 返回默认行高。返回 44; } else { // 返回默认行高的三倍。返回 44 * 3; } }
    猜你喜欢
    • 2022-05-16
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多