与UIScrollView AutoLayout With 'Footer' Pinned to Bottom of Screen相同。
我希望屏幕内容可变高度加页脚。当内容很少时,页脚应粘在底部并在其与内容物之间留有间隙。当内容不仅适合屏幕时,屏幕应该是可滚动的,页脚应该出现在内容之后。
Few contents: Lots of contents:
+---------+ +---------+
| Content | | Content |
| Content | | Content |
| Content | | Content |
| | | Content |
| | | Content |
| Footer | | Content |
+---------+ < Screen bottom > +---------+
| Content |
| Footer |
我需要它兼容iOS7。
我没有关于实现的具体要求(scrollview,tableview等),但是我想通过autolayout(或任何更早自动完成该事情的方式)来完成所有这些。
我不介意让一些代码响应两种不同的情况,只要它支持动态内容高度。我并不热衷于监控UI大小的变化,但是,如果可以以一种相当干净的方式完成,那就这样吧。
答案 0 :(得分:0)
- (无效)viewDidLayoutSubviews { [_tableView reloadData];
CGRect newFrame = _toolBar.frame;
newFrame.origin.y = _tableView.contentSize.height > CGRectGetHeight(_tableView.frame) ? _tableView.contentSize.height : CGRectGetHeight(_tableView.frame);
_toolBar.frame = newFrame;
}
我认为代码可以自我解释。 :)