Toolbar placement off with Interface Builder - iphone

I have a view xib that I'm manipulating through IB (for various reasons) and it will be launched as a modal view in code. I have a Toolbar at top and another one at bottom with some other UI elements in between. When I run the app, the placement of the top Toolbar isn't as I see it during the layout in IB.
In IB, the top Toolbar is placed at top below the status bar correctly and the next UI element (a label) appears below it. However, in the simulator, the top half of the Toolbar appears underneath the status bar and thus making it look cut off and there is a lot of space between the Toolbar and the label, which isn't reflected in the layout in IB.
For modal views, should the height of the view be different? If so, what does it need to be?
The view's height is set to default height value of 480.

Is the style of the status bar set to Translucent Black in IB? This causes the status bar to not consume any space and as a result "float" above the underlying Views.

Related

Gap above ContentView / not the same height as UIScrollview - xib

Issue: gap above where contentView starts. Should be 0.
Despite setting the content view top bottom leading and trailing to 0, the content view has a gap at the top. I am using auto layout only.
Scrollview background is blue &
Content view is grey for easy viewing.
If I set the content view to equal heights as the scroll view, I get an error. And this doesn't seem like the right approach away. According to this setting equal height is optional:
Apple auto layout scrollview page
I do set equal widths.
Entire Screen:
Top of Scroll view:
Bottom of scroll view -> this is right - flush with bottom of scroll view (not sure if that matters)
Constraints:
Subview constraints:
Please help!! Also I am using xib files - not sure if that matters.
Thank you!
You'll notice that the gap is equal in height to the navigation bar.
The gap is there because by default iOS assumes that when using a translucent navigation bar, scroll views (and their subclasses like table views) begin at the top of the screen, behind the translucent navigation bar.
iOS then assumes you do not want your content hidden behind the translucent navigation bar, so it applies a top content inset to any scroll view, of height equal to the navigation bar height.
This behavior can be overridden in two ways:
Unmark Adjust Scroll View Insets on the view controller (see image below)
Make your navigation bar not translucent. If you're using a Storyboard, select the navigation controller that contains the affected view controller, and unmark the Translucent checkbox.

How to add a titlebar to a popover

I'm trying to replicate the appearance of the (no longer functional) Degrees app, but I can't figure out the components used to make the title bar (highlighted here in red).
I've managed to get my app running as a menu bar agent, and I've wired up a popover to display a window view on click. But it's not quite right: my window's title bar disappears when in the popover, and the bar used in the Degrees app is wider than the one provided by the stock window control.
How might I mimic the appearance here? it just an ImageView?
Popover's don't show window title bar's as you've discovered.
Just add an NSView at the top of your window view and add a label for the title and a button for the "Done" button to create your top bar with desired height. Then add a horizontal line to the bottom of this title view and programmatically set the background color of its layer to whatever you desire. Offset all your other views by that bar height.
Basically:
[Window]
[View]
[View (Title Parent)]
[NSTextField]
[NSButton]
[Horizontal Line]
[Other Views]
For getting the gray background, in your NSWindowController windowDidLoad,
self.titleParentView.wantsLayer = YES
self.titleParentView.layer.backgroundColor = [NSColor grayColor].CGColor;
where titleParentView is an IBOutlet connected to the view you created above in the xib/storyboard

Auto resizing in a tab bar is not working

I have a view with a tab bar and a navigation bar. I have a few buttons and textfields in the view. I have some empty space left at the bottom of my view.
While testing on 3.5 inch screen the empty space is occupied by the tab bar. But, on a 4 inch screen I can see the space left clearly. I tried auto resizing every way but it's not working.
Should I go for creating a separate view for the 4 inch screen?
While working with tab bar you dont have to bother for leaving space for tab bar, it'll make it's space by resizing (not cropping) the height of your view. In result the screen size will minimize.
But in this case view's AutoResizingProperty Must be like:
[yourView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
Or if you are dealing with XIB then it should look like:
With these setting your view will resize itself on bot size of windows.

how do I have the navigationItem.titleView to be behind left and right bar button item

Is it possible to have the titleView to be behind the left and right bar button item on a navigation bar? I've set my titleView to have a width of 320 and it covers the left and right bar button item. I wonder if there is a way to move it to the back?
In my experiments, it appears that the titleView is always drawn after (above) the left and right bar button items. You could try spelunking the view hierarchy and using sendSubviewToBack:, provided that the title view is ever made part of the navigation bar's hierarchy.
If you can render the effect you're trying to achieve into an image, you could set that as the backgroundImage of the navigation bar, but this may not be practical.
Remember that you'll likely need to account for interface rotation in any case, since the navigation bar height (on iPhone) goes from 44px in portrait to 32px in landscape).

Using translucent UINavigationBars

I am using InterfaceBuilder to set up my app. I have several views being controlled by a UINavigationController. In IB I set up the views using the simulated metrics to position the elements below the Navigation Bar.
I have a background texture that is placed in the window object of the Main.nib so that it is shared throughout the app. I want that texture to be visible behind a transucent navigation bar.
If the actual navigationBar's style is BlackOpaque the elements of the various views are positioned correctly below the navBar when the app is run.
If I set the NavigationBar to be translucent, view elements are repositioned to the bottom of the status bar when the app is run so that they are visible behind the navigationBar, even though they are positioned correctly in their various nib files.
How do I defeat this behavior?
I figured out the answer...
If you do NOT want objects to be slid up to be positioned behind a translucent NavigationBar, In IB, set the simulated metrics for the navBar to none, and position the view elements as desired.