如何使用具有自动尺寸的UITableView更改该单元格内UITableViewCell的高度?

时间:2015-08-05 07:50:02

标签: ios swift uitableviewautomaticdimension

到目前为止,我试过了:

@IBOutlet weak var requestDateButtonBottomConstraint: NSLayoutConstraint!

requestDateButtonBottomConstraint.constant = sender.selected ? 0 : 260

我也试过框架方法:

var cellFrame = self.frame
cellFrame.size.height = sender.selected ? 44 : 260
self.frame = cellFrame

没有人在工作......

1 个答案:

答案 0 :(得分:0)

只需返回

中的实际高度

UITableViewDelegate

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (something) {
        return 260.0
    } else {
        return UITableViewAutomaticDimension;
    }
}
相关问题