flaviusilaghi
flaviusilaghi

Reputation: 661

View drawn under status bar

So i managed to load another view when someone presses a button ,but it loads it to high. `i don't know why this happens. The difference is exactly the top bar hight. This is my code: In the delegate i have:

- (void)flipToAbout {
AboutViewController *aaboutView = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
[self setAboutController:aaboutView];
[aaboutView release];

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES];
[homeController.view removeFromSuperview];
[self.window addSubview:[aboutController view]];
[UIView commitAnimations];}

In the about view i didn't change anything.Please tell me what is the problemm .Thanks.

Upvotes: 0

Views: 2015

Answers (1)

Caleb
Caleb

Reputation: 125037

The problem is that you're adding your view directly to the window without accounting for the navigation bar. Normally, if you have a navigation bar, you use a navigation controller to manage your view controllers. Pushing a view controller onto the nav controller's stack causes the nav controller to add that view controller's view to the window for you, and you don't have to worry about the nav bar. Since you're doing it by hand, though, you'll want to reposition the view after you add it to the window.

Note that this problem doesn't have anything to do with nibs except that you load your view from a nib. The same thing would happen if you created the view programmatically.

Upvotes: 1

Related Questions