Reputation: 24426
What is the best way of having a block of screen run by it's own view controller, whilst the rest of the app runs as normal, switching between views etc.
So the block of screen would be a permanent fixture (tho could be hidden), while the user can switch between tab, push new views etc?
Is there a way to programmatically attach a view to a view controller to do this, or is there some other method?
-----------------------------------------
| |
| nav bar or tool bar |
-----------------------------------------
| |
| |
-----------------------------------------
|view to be attached to view controller | < this block stays even when in other views
-----------------------------------------
| |
| |
| |
| main bit of the view |
| changes according to tab |
| |
| |
| |
-----------------------------------------
| | | | | |
| | | | | | < tab bar
| | | | | |
-----------------------------------------
Upvotes: 0
Views: 794
Reputation: 7644
Instead of attaching to view controller, create the view in appDelegate or a singleton instance of the view and whenever a new view is pushed/switched, this view is moved to the front by writing
[self.view addSubview:_yourStaticView];
in the view did load methods of each view controller class. A single UIView controller has a stack, so it cannot render multiple views at the same time, it's either one or the other. Whenever you want to remove this view, write:
[_yourStaticView removeFromSuperview];
You can change the contents of this view just as you would with a UIView!
Upvotes: 1