Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating View over UITableView in RootViewController

In the main UITableView for a RootViewController.

How can I add a View over a RootViewControllers TableView, with its position relative to screen and not to TableView, so it doesn't scroll with it?

Note - it will be a progress bar showing new data for the table downloading progress.

like image 265
David Casillas Avatar asked Nov 01 '11 22:11

David Casillas


1 Answers

It would help if you posted your code, but: you're presumably adding the UITableView to your RootViewController with something like this:

[self.view addSubview:myUITableView];

Just add your floating view in the same way (i.e. add it to your view controller, not to your UITableView). If you add it after you add the table view, it will already be "above" the table view. Otherwise you can bring it to the top with something like this:

[self.view bringSubviewToFront:myOverlayView];

Your overlay view should sub-class UIView, and it should set its own backgroundColor to [UIColor clearColor] in order to make it transparent. In order to allow the user to continue interacting with the table view (which you presumably want to have happen), in your overlay subclass override hitTest:withEvent: and return the table view (instead of returning self which is the default behavior). This will pass all touches on to the table view underneath.

like image 93
MusiGenesis Avatar answered Nov 10 '22 22:11

MusiGenesis