0

私は3つのカスタムを持っていますTableViewCellsheightForRowAtIndexPathストーリーボードで AutoLayout を使用できないため、コードで設定する必要がある 3 つのセルの 1 つがあります。

特定のカスタムを設定heightForRowAtIndexPathする方法はありますか?TableViewCell

私のheightForRowAtIndexPath

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    id model = self.combinedModel[indexPath.row];

    // Custom Table View Cell Two
    if ([model isKindOfClass:[Data self]]) {

        return 500;
    }
    // Custom Table View Cell One and Three
    else {
        // Not sure what to put here, but need to put something without setting a height
    }
}
4

2 に答える 2

4

コードで次のことを行います。

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    id model = self.combinedModel[indexPath.row];

    // Custom Table View Cell Two
    if ([model isKindOfClass:[Data self]]) {
        return 500;
    } else {
        return tableView.rowHeight; // return the default height
    }
}
于 2014-11-10T00:00:50.557 に答える
1

「高さを設定せずに何かを置く」というのは意味がありません。テーブル ビューにすべてのセルの高さを指定する必要があります。他のセルに使用しているデフォルトの高さを指定します。

于 2014-11-09T23:58:52.130 に答える