Search code examples
iosuitableviewaddsubview

Fixed subview at bottom of the screen over TableView


I have a subclass of UITableViewController, and I want to add a view at the bottom of the screen which should stay stuck at the bottom even when I scroll the table. That view should remain fixed at its position while table can be scrolled.

Any suggestions?


Solution

  • Instead of subclassing UITableViewController you can instead subclass UIViewController which contains a standard UIView set as it's view outlet. Then place a UITableView inside this UIView.

    So you would have: UIViewController > UIView > UITableView

    This way you can add the sticky view to the UIView on top of the UITableView and it will stay stationary.

    One thing to note with this is you may have to pass touches down from the sticky view if you still want the user to be able to scroll when touching the sticky view.