在 UIButton 可见的情况下滚动 tableView

Scroll tableView with UIButton visible

我有一个包含原型单元格的 TableView 和一个带有按钮的 UIView。它看起来像这样:

我必须一直滚动到 tableView 的底部才能找到按钮。

我想要实现的是当 tableView 在屏幕的上部滚动时,让按钮在底部可见。

我该怎么做?

我不喜欢放弃 UITableViewConvtroller 的想法,所以我最终通过:

//self.floatingActionButtonYOrigin is initialised with the initial Y origin in viewDidLoad.

override func scrollViewDidScroll(scrollView: UIScrollView) {
    let tableBounds = self.tableView.bounds
    var floatingButtonFrame = self.bottomRightButton.frame;
    floatingButtonFrame.origin.y = self.floatingActionButtonYOrigin + tableBounds.origin.y;
    self.bottomRightButton.frame = floatingButtonFrame;
}

虽然它不考虑方向变化..