5

で奇妙な動作が発生していUITableViewます。で をセットアップしUIViewControllerましたUITableView。、、セクション フッター ビュー、および動的な高さを持ついくつかのUITableViewが含まれています。tableHeaderViewtableFooterViewUITableViewCell

問題は、tableFooterViewがテーブルのコンテンツの下部に配置されるのではなく、テーブルの中央のどこかに表示されることです (セルの上にカーソルを置きます)。どうやら、テーブルのcontentSizeプロパティも間違ったコンテンツ サイズ (具体的には高さ) を返しているようです。

tableFooterViewただし、カスタム セクション フッター ビューは適切な場所 (および表の中央にある実際のセクションの下) に表示されています。

何が起こっているのですか?

注: カスタム テーブル ビュー (自動レイアウトを使用して動的な高さを処理) で、「あいまいなレイアウト: 2 つのビューが垂直方向にあいまいです」と表示されます。警告が表示されますが、実行時に正しくサイズ変更されています。

テーブルのセットアップは非常に簡単です。

// Set table header/footer view
self.myTableView.tableHeaderView = self.myTableHeaderView;
self.mainTableView.tableFooterView = self.myTableFooterView;

// Table delegate methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [self heightForCellAtIndexPath:indexPath];
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [MyCustomCell defaultHeight];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {

    if (section == 0) {
        return self.mySectionFooterView;
    }

    return [UIView new];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {

    if (section == 0) {
        return [self heightForSectionFooterView];
    }

    return 0.01f;
}
4

3 に答える 3

2

今のところ EstimatedHeightForRowAtIndexPath: のように見えます: フッタービューを台無しにします:

https://twitter.com/steipete/status/420538600384888832

于 2014-04-06T01:52:56.050 に答える
1

目的の結果を得るために、ヘッダーとフッターのみ (行なし) の追加セクションを使用することになりました。自動レイアウトの動作がおかしいのかもしれません。「あいまいなレイアウト: 2 つのビューが垂直方向にあいまいです。」というメッセージがまだ表示されますが、UI は良さそうです。

于 2014-03-18T09:35:16.747 に答える