で奇妙な動作が発生していUITableView
ます。で をセットアップしUIViewController
ましたUITableView
。、、セクション フッター ビュー、および動的な高さを持ついくつかのUITableView
が含まれています。tableHeaderView
tableFooterView
UITableViewCell
問題は、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;
}