Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Title bar on top of view?

bmzerobmzero Posts: 20Registered Users
edited February 2010 in iPhone SDK Development
I've searched all over for the answer for this. I think the problem is not knowing what to search for.

Basically, how do I keep my views either below the title bar (vertically below) or keep my views on top of (stacking order) the title bar?

Unless I move my view objects down, they all look like this:

iphone.png

Please pardon my noob'ness and thanks for the help.
Post edited by bmzero on
· ·

Replies

  • scottiphonescottiphone Posts: 802Registered Users
    edited September 2008
    Do you use Interface Builder? If so set the window to have a status bar.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    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?
    · ·
  • scottiphonescottiphone Posts: 802Registered Users
    edited September 2008
    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.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    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?

    How are you guys getting around this?

    Thanks for the help.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    I'm adding the view to the window like so:
    [self.window addSubview:[sendToFriendViewController view]];
    
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    Here is what I'm working with.

    viewSettings.png

    I set the background color of the view to yellow to illustrate my problem.

    Running it in the simulator gives this:

    view.png

    Obviously there is some problem with the view remaining static to the top of the iphone versus below the status bar.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    Here are the window settings:

    window.png
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    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.

    peoplePicker.png
    · ·
  • PhoneyDeveloperPhoneyDeveloper Posts: 1,431Registered Users
    edited September 2008
    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.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    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.

    Moving to Navigation is the last resort.
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited September 2008
    Any suggestions here? I'm stumped.

    I can hack through the view issues, but I can't figure out any way to keep the people picker below (vertically, not stack order) the status bar.
    · ·
  • unfalksterunfalkster Posts: 4New Users
    edited February 2009
    Hi bmzero,
    I have exactly the same issue... Have you found anything new ?
    · ·
  • bmzerobmzero Posts: 20Registered Users
    edited February 2009
    unfalkster wrote: »
    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.
    · ·
  • unfalksterunfalkster Posts: 4New Users
    edited February 2009
    Ok, I might have found some leads.

    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...
    Image 1.png
    1 x 1 - 4K
    · ·
  • fnergfnerg Posts: 2New Users
    edited May 2009
    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.

    In your application delegate, add
    IBOutlet UINavigationController* navControl;
    

    and
    @property (nonatomic, retain) IBOutlet UINavigationController* navControl;
    

    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
    [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.
    · ·
  • Sayid CohenSayid Cohen Posts: 1New Users
    edited January 2010
    The following code solve it for me:
    - (void)viewWillAppear:(BOOL)animated {
    	// to fix the controller showing under the status bar
    	self.view.frame = [[UIScreen mainScreen] applicationFrame];
    }
    
    · ·
Sign In or Register to comment.