If you embed the UIButton in a UIView, then you can use a UITableVIewController.
Here is the stripped down code of one of my UITableViewController instances. There is a UITableView and on the bottom of the page there is a UIView with a UIButton on it:
class ViewController : UITableViewController
{
@IBOutlet private weak var floatingView: UIView!
override func viewDidLoad()
{
super.viewDidLoad()
self.initSaveView()
}
override func viewWillLayoutSubviews()
{
super.viewWillLayoutSubviews()
self.tableView.bringSubviewToFront(self.floatingView)
}
fileprivate func initSaveView()
{
self.tableView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.floatingView.frame.height, right: 0.0)
self.tableView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.floatingView.frame.height, right: 0.0)
self.floatingView.frame.origin.y = self.tableView.bounds.origin.y + self.tableView.frame.height - floatingView.frame.height
self.floatingView.autoresizingMask = .flexibleTopMargin
self.view.addSubview(self.floatingView)
}
}
extension ViewController
{
override func scrollViewDidScroll(_ scrollView: UIScrollView)
{
floatingView.frame = CGRect(x: self.floatingView.frame.origin.x, y: self.tableView.bounds.origin.y + self.tableView.frame.height - floatingView.frame.height, width: self.floatingView.frame.size.width, height: self.floatingView.frame.size.height)
}
}
Hopefully this will get you started. The floatingView
was added using the Interface Builder (Simply drag a UIView to the top of the UITableViewController bar, then add your Outlet).