I have TabBar
with 2 tabs. At some point, from either of the 2 tabs, I want to add a view that is visible on both tab views but behind the TabBar
.
So I thought, insert a subview into the TabBarController
but below the TabBar
.
This works fine in principle and I have the view behind the TabBar
but now covering my 2 tabs as I wanted. However, it doesn't actually load. Just its background loads and only viewDidLoad()
is called, not viewWillAppear()
or any others.
I have also tried calling addChildViewController(myVC)
on the TabBarController
which has no effect, and also manually calling viewWillAppear()
on the view controller I add which also has no effect (and I'm also dubious about whether manually calling viewWillAppear()
is permitted or not?).
Is what I'm trying to do possible? What am I missing? Or should I be attempting this some other way?
For some reason, when inserting a subview into a UITabBarController
behind it's UITabBar
, although the view is visible to the user, the system itself seems to think it is not and so although viewDidLoad()
is called, viewDidAppear()
and subsequent methods are not.
However, adding a subview above the UITabBar
seems to work fine. So I solved this by adding my own new UITabBar
as a subview to the UITabBarController
(set up basically exactly as the default one would be) and then removing the UITabBarController's
default UITabBar
.
Then when later inserting my view into the UITabBarController
, I insert it as I was doing originally but instead below/behind my custom UITabBar
and it seems to load fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With