Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a button that floats over a UITableView

I have a TableView that displays a list of posts. I would like to add a button that floats over the TableView and the button doesn't move as the user scrolling through the posts. The button will enable a user to post. How can I implement this? I can't seem to add a superview to my tableview.

Google Plus app does something similar, but if you don't have the app, the official website also presents this behavior. The button is located on the bottom left.

Thanks!

like image 427
Martin Muldoon Avatar asked Oct 19 '22 05:10

Martin Muldoon


1 Answers

There are a couple ways to handle this without needing to lose the table view controller.

Use a container view for the table view controller

If you are using a storyboard, setup a view controller with the button and a container view. In that container view, have the table view controller. You can use delegation, notifications, or key value observing to keep the two view controller in sync.

Add the button to the window instead of the table view controller

If you just want the button to simply float over the table view, then you can add the button to the window instead of the view. This has to be done at runtime.

like image 123
Jeffery Thomas Avatar answered Oct 21 '22 04:10

Jeffery Thomas