Adding custom view above tab bar controller/navigation controller?
Add the view to the tabBarController View itself:
[self.tabBarController.view addSubview:yourView];
I had the same problem and ended up doing something like this:
newView.frame = tabBarController.tabBar.frame
tabBarController.view.addSubview(newView)
Adding the view to the tabBarController and using the frame of the current tabbar as the position of the new view did the trick.
You could simple addSubview to window:
[self.view.window addSubview:myView];
There isn't really any good way to do this. The various subviews of UINavigationController and UITabBarController are both private, and trying to mess with them is likely to not work correctly. And Apple doesn't give us the tools to create "container" view controllers, so you can't easily embed the UINavigationController/UITabBarController inside another view controller or recreate UINavigationController/UITabBarController yourself.
Your best bet is probably to go ahead and try to create your own "container" view controller, and deal with some things not working right. In particular, the contained view controller's parentViewController
will return nil, and therefore various other things on the contained view controller or its sub-controllers will be broken (e.g. the interfaceOrientation
property will be wrong, presentModalViewController:animated:
might not work right). Other things may be broken too.
Or you could wait until some future version of iOS actually has support for us to create container view controllers (if ever), and then support only that version and up.