Bob Yousuk Bob Yousuk - 1 year ago 100
iOS Question

Creating a UIView that sticks to bottom of UITableView

I have a

grouped UITableView
and I'd like to add a UIButton to the very bottom of my
. I'm using Storyboard and a UITableViewController. I'm not quite sure where I need to add code or drag/drop UI Elements. I've tried adding a UIView as the footerview in Storyboard and then adding a button to that view, but this doesn't have the desired effect of always staying on the very bottom of the view, similar to a tabbar. Also, the button should always stay in the forefront, and the UITableView should scroll behind it.

// tried this but it didn't work:
self.tablview.tableFooterView = [[UIView alloc] initwithview...]

Answer Source

If you want your UIButton to be at the bottom of the screen regardless of the scroll position of the UITableView (i.e., not inside the UITableView) then you should probably not use a UITableViewController subclass. Instead, if you use a UIViewController subclass, you can simply add a UITableView to your root view property and add a UIButton or some other view (such as a UIToolbar, etc) with appropriate layout constraints to place it at the bottom of the screen - or wherever you want it. This is not really possible with a UITableViewController subclass, as the root view property is required to be a UITableView instance.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download