views:

21

answers:

2

I have a Navigation Controller in my main view. And I use the following code to add the navigation view when needed.

[self.view addSubview:navController.view];

However, the the navigation bar is not positioned correctly. I have posted a pic below. Anyone knows what is the potential problem?

alt text

A: 

I solved this problem by using presentModalViewController but don't quite understand why..

nababa
A: 

Just for the future, your self.view frame takes into account the 20px up top for the status bar, so if your navcontroller.frame = self.view.frame you will always have this gap. Using a modal is one way to solve the problem (and it looks like a good use of it). Another is to manually create the rectangle you want your subview to be in.

MishieMoo