Constraint value for navigation bar in storyboard - ios

I want to add a constraint to the navigation bar I am adding via storyboard. The purpose is for the navigation bar to be fit to the border on the left and right side. The current canvas value on the screen is -16, and it shows up correctly when I run the app. However I can't figure out why -16, and when I set it to 0 there is a gap to the border.
To reproduce, create a blank single view ios project, drag a navigation bar into the story board and try to add a constraint.
xcode 6.3.1

Removing the tick on "Constrain to margins" will fix it.

Related

How to show navigation bar in Interface Builder preview storyboard (assistant editor)

I am doing autolayout works in Storyboard and previewing the result in Assistant Editor > Preview
How can I show navigation bar in the preview?
Take a dummy view and give its height equals to the navigation bar height. (navigation bar height remain same in each device). when u done ur pixel perfection than uncheck installed from attribute inspector of that view or just remove the view.
I suggest another way - just use top constraint, while you container view will have y = 0, you can set top constraint to 44px, in this case you will see warning, but all stuff at your screen will be at the same positions, but preview will display your screen like you have navigation bar. When everything is ok, just set top constraint to 0. I guess this solution is really convenient.

How to place any view below any other view which is getting it's position from code

I've created 4 subviews of white color & a yellow one as you can see in reference image I've shared below.
And I've programmatically changed the position of Tabbar from bottom to top just below to navigation bar as you can see in below image (When it is running in the simulator).
Now since I've constraints for that yellow view in image as follow
It is appearing just below to navigation bar but I want it to be displayed just below the Tabbar.
Since Tabbar is getting its position programmatically & other views (including yellow view) are getting their positions from the storyboard.
And since storyboard UIelements are get settled before any other UIelement which are coming from the program or at least get their position from programmatically.
What could be the best way to achieve what I want.
Please refer my storyboard as well to get more understanding. (Refer Below image)
I also want to fit all 5 subviews in the space between tabbar & bottom of the screen. I want to calculate 1/5th of that space & assign this height to each subview. I'd later reduce few pixels to separate them.
Why not add the height of the tab bar to the yellow view's top position? That way, you'd set the constraint something like:
Fajar.top = top + 44
If the tab bar is always visible, then that should work. But of course, if the tab bar only appears at times, you'd probably have to change that constraint programmatically depending on the change ...

iOS storyboards - UINavigationBar not appearing when I add it

I added a UINavigationBar to a detail controller scene, but when I run my app the UINavigationBar does not appear. Why is it doing this ? I have the custom class set to the controller I want it too, but its not appearing, here is a screenshot.
but when I run this app, I dont see the "Title" bar or anything.
To add constraints select your navigation bar and click in the icon as in the picture.
uncheck "constrain to margins" as you want the navigation bar to snap in the boards of the screen, select the up and left red dots lines and add the value 0 to the drop boxes, meaning 0 pixels from the left and top of the screen.
Select Update frames and click in add constraints.
I can see in your screenshot you have other screen with problems (red icon next to the view controller) you should also fix that, click in the icon for more details about the error/warning
I am not sure if I understand what you are trying to do, but try this,
Select the detail view and go to the xCode menu and select editor->Embed in-> Navigation Controller.
I hope it helps
Add constraints to your navigation bar. However, IcaroNZ suggested the best way for navigation

Autolayout doesn't work?

So I'm creating my app in storyboard, and i'm using an navigation controller, added an add view, and trying to auto layout stuff there.
But the problem is, i only get blue guided lines when I'm near the corner left and right. So it's basically not looking at my Navigationbar above.. and just ignoring it.
Also, when I'm switching the simulator to a 3.5 inch (I'm making it in 4 inch) the buttons and labels will disappear underneath it. And they are added to Auto layout blue lines?
The blue lines are not AutoLayout, but just lines that guide you when placing your views. Auto Layout only comes in when you start adding constraints. Check out Apple's Autolayout guide:
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html
Control drag from the label to the navigation bar and it will show the below window. The first option is for you to create the constraint from the Navigation Bar bottom.
The Top Layout Guide is a iOS 7 specific feature which marks the bottom line of the navigation bar. The total height of the navigation bar (if present) plus the height of the status bar (if present) equals the toplayoutGuide.length

In iOS 7, how do you access the topLayoutGuide / bottomLayoutGuide in Interface Builder?

Using XCode 5, downloaded today. iOS 7. When I run app the table view header appears underneath the navigation bar, I don't mind it scrolling underneath the navbar but I'd like for it to appear unobstructed initially. I am trying to figure out how to use the topLayoutGuide mentioned in the iOS 7 transition guide, which says you can set a constraint relative to it, but doesn't explain how.
Anyone know?
Transition guide here:
http://tinyurl.com/mgdl4sg
Just realized that my storyboard was still set to XCode 4.6
You have to go to the File Inspector (icon that looks like a file icon in the right navigation panel in Xcode) and then under "Interface Builder Document" where it says "Opens in" change to Default (5.0) and / or "View as" iOS 7.0 and Later
Then your IB document will show the guides inside the left hand navigation panel under the view controller
Often if you select the view, and click the "Pin" button at the bottom right, pin the vertical spacing, and the dropdown will have an option to use the topLayoutGuide
In my Storyboard, was still have trouble getting my UITableView to pin the vertical spacing between the top of the table view and the top layout guide. Every time I control-dragged I would get it pinning to the bottom of the table view instead of the bottom. But then I tried manually dragging the table view so that it appeared below the nav bar in IB and then control-dragged and the vertical spacing finally worked.
I had the same problem, and in Storyboard when I set the top bar to Opaque the top of the scrollView changed so that it wasn't obscured by the nav bar. Makes sense, but it's unfortunate that you can't use a translucent nav bar and get the same effect.

Resources