Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom view above tab bar controller/navigation controller?

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?

like image 313
xil3 Avatar asked Jul 25 '11 19:07

xil3


2 Answers

Add the view to the tabBarController View itself:

[self.tabBarController.view addSubview:yourView];
like image 57
Sebyddd Avatar answered Sep 18 '22 19:09

Sebyddd


You could simple addSubview to window:

[self.view.window addSubview:myView];
like image 40
Borut Tomazin Avatar answered Sep 22 '22 19:09

Borut Tomazin