Do you use Interface Builder? If so set the window to have a status bar.
Yes, I use IB. I'm having trouble actually selecting the window. Am I missing something? I can select the view all day long, but I have no idea how to select the window. Any hints?
If you've used one of the project templates you should have a Window in your MainWindow.xib. Select it in IB and do a get info. Status Bar can be set for none, black, etc.
Assuming your view is added to the window and is set to autosize then it should conform to the status bar. You can try moving the view down if it's already added to the window in IB.
As a last resort you can move the whole frame down in the awakeFromNib but that's a patch.
I've gone in and selected "gray" for the window's "status bar" under "simulated metrics", and I double checked that the view was set to "scale to fill", but it still appears under the status bar when I run it in the simulator or on the phone.
I can move each of the components down within the view in IB, but that seems like a hack.
In IB, while editing the view, I can set the status bar to "gray" under simulated metrics, but all that does is make everything taller (it doesn't shrink the view vertically accordingly, it just makes the IB window taller), which has no affect on the size of the view.
This seems overly complicated. You would think it would be obvious that a view should not appear under the status bar in an application. Am I still missing something?
I just noticed something else that might help shed some light on this issue. When I open up my peoplePicker, it has the same problem as the other views; being under the status bar. Seeing that i have no control over the layout of the people picker, it seems this may be an issue with the window or how I'm adding a view to the window.
Why don't you just build a Navigation Based app from the template and see how it works? That is a project that does exactly what you want and it works.
Looking back on it, that would probably have been the way to go, but at this point not knowing why this is happening is bothering me. Maybe it's my OCD kicking in.
Hi bmzero,
I have exactly the same issue... Have you found anything new ?
Nope. I gave up on it and moved on to something else. Please post back if you find out the solution. Hopefully by now, the right way to to this is public knowledge.
I used to have a simple view into a nib file (say TheView.xib), with, as File's owner, a subclass of UIViewController.
But if I add a viewController with IB in the mainWindow.xib nib file, setting the nibname "TheView" in the attribute inspector (cmd+1) and accessing this controller in my code with the IBOutlet keyword system, it's seems to work.
I am conscious that I am not very clear there but in fact all I did was just copying the mechanism in place when you use the Xcode new project assistant "View based application".
For some reason, you have to have your controller (.m file, subclassing UIViewController) represented somehow by an IB viewController (see in attachment).
I am kind of new with the iPhone SDK, so all these things are still difficult to understand, but I hope I helped...
So first thing, instead of putting the navigation bar in your view, and then adding the view to your window, you want to open your MainWindow .nib, and add a Navigation Controller there.
to the header file, then synthesize that in your .m file.
In Interface Builder, drag a Navigation Controller from the library, and drop it into the inspector. Context click and drag from your app delegate to your navigation bar, and connect it to your IBOutlet.
Finally just add
Code:
[window addSubview:[navControl view]];
to your applicationDidFinishLaunching method, and everything will be aligned the way it needs to be.
The takeaway I think is to use the right View Controllers, and let them deal with their own alignment.
- (void)viewWillAppear:(BOOL)animated {
// to fix the controller showing under the status bar
self.view.frame = [[UIScreen mainScreen] applicationFrame];
}