Ios tableFooterView未在表格底部正确对齐
我在使用Ios tableFooterView未在表格底部正确对齐,ios,uitableview,autolayout,tablefooterview,Ios,Uitableview,Autolayout,Tablefooterview,我在使用UITableView时遇到了一个奇怪的行为。我用UITableView设置了一个UIViewControllerUITableView包含一个tableHeaderView、tableFooterView、一个节页脚视图和一对具有动态高度的UITableViewCells >问题是,代码> Table FooTyVIEW < /C> >出现在表中间(徘徊在单元格上),而不是在表内容的底部对齐自身。显然,表的contentSize属性也返回了不正确的内容大小(特别是高度) 自定义区段页
UITableView
时遇到了一个奇怪的行为。我用UITableView
设置了一个UIViewController
UITableView
包含一个tableHeaderView
、tableFooterView
、一个节页脚视图和一对具有动态高度的UITableViewCell
s
<> >问题是,<>代码> Table FooTyVIEW < /C> >出现在表中间(徘徊在单元格上),而不是在表内容的底部对齐自身。显然,表的contentSize
属性也返回了不正确的内容大小(特别是高度)
自定义区段页脚视图出现在正确的位置(并且在实际的
// 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;
}
最后,我使用了一个额外的部分,只包含页眉和页脚(没有行),以获得所需的结果。也许自动布局有点奇怪。我仍然得到“模棱两可的布局:两个视图在垂直方向上模棱两可”,但UI看起来不错 现在的估计权重如下所示:页脚视图混乱:
尝试设置footerView.autoresizingMask=.flexibleWidth 示例代码:
let footerView = Bundle.main.loadNibNamed(String(describing: MyFooterView.self), owner: nil, options: nil)?.first as! MyFooterView
footerView.frame = CGRect(origin: .zero, size: CGSize(width: view.bounds.width, height: 80))
footerView.autoresizingMask = .flexibleWidth
tableView.tableFooterView = footerView
所以,我不是唯一一个。很高兴知道。:)我花了很长时间才意识到问题不在我的程序上!!!这么多的想法的框架将工作的开箱即用!iOS 8.1中仍存在tableFooterView对齐问题。你的解决方案奏效了。。。使用没有行的节标题。哇!!