Gap At Top Of View Goes Away

Discussion in 'iOS Programming' started by zachsilvey, Dec 16, 2010.

  1. zachsilvey macrumors 6502

    Joined:
    Feb 5, 2008
    Location:
    Battle Ground
    #1
    Why is it that when I use this code in the AppDelegate the gap between the UILabel and the top of the view I created in the xib goes away. Am I adding the subview the wrong way?

    Code:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
        
    	MainViewController *mainView = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
    	
    	[self.window addSubview:mainView.view];
    	
    	[mainView release];
        
        [self.window makeKeyAndVisible];
        
        return YES;
    }
    
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Is the (missing) gap about 20 pixels high, the same height as your status bar?
     
  3. zachsilvey thread starter macrumors 6502

    Joined:
    Feb 5, 2008
    Location:
    Battle Ground
    #3
    Exactly. I have been googling like crazy to figure this out to no avail.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    Does your MainViewController XIB have a Status Bar set appropriately in the Simulated User Interface Elements?
     
  5. zachsilvey thread starter macrumors 6502

    Joined:
    Feb 5, 2008
    Location:
    Battle Ground

Share This Page