我遇到一個奇怪的行爲UITableView
。我用UITableView
設置了一個UIViewController
。 UITableView
包含tableHeaderView
,tableFooterView
,部分頁腳視圖以及具有動態高度的幾個UITableViewCell
。tableFooterView在表格底部沒有正確對齊
問題是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;
}
的tableFooterView對齊問題仍然在iOS 8.1中發生。您的解決方案工作...使用沒有行的節標題。好哇! – RyJ