I tried the following code, in an attempt to get the custom view displaying above the tab bar controller (which happens to have a navigation controller within all of it’s tabs).
The problem is that it overlays on top of the navigation bar, and I want the navigation bar to be moved down.
I tried setting the frame of the tab bar controller, but that didn’t move it at all.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
//self.tabBarController.view.frame = CGRectMake(0, 62, 320, 320);
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
// setting up the header view
self.headerView = [[HeaderView alloc] initWithFrame:CGRectMake(0, 20, 320, 42)];
[self.window addSubview:self.headerView];
// setting up facebook stuff
AgentSingleton *agentSingleton = [AgentSingleton sharedSingleton];
agentSingleton.facebook = [[Facebook alloc] initWithAppId:APP_ID];
return YES;
}
Any ideas?
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
parentViewControllerwill return nil, and therefore various other things on the contained view controller or its sub-controllers will be broken (e.g. theinterfaceOrientationproperty 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.