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

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.

Related

Unable to put view above navigation bar

I am trying to design a side menu, whose height would be equal to screen height (therefore hiding the navigation bar too). However I am unable to get the same.
I have put constraints as this:
and in viewDidLayoutSubviews()
I have mentioned - sideMenuTopConstraint.constant = -1 * (self.navigationController?.navigationBar.frame.height)!
However I see no change. Also by increasing the height of the side menu view in storyboard, I see that it is always below the nav bar. How do I make it appear above it?
You need to add the view to window as a subview, that should bring this view above the navigation bar as needed.
This is because window is the root of all the views.
UIApplication.sharedApplication().keyWindow?.addSubview(desiredViewHere)

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 ...

Navigation bar not occupying entire screen

Im trying to create a UINavigationBar using storyboard but the UINavigationBar is not occupying the entire screen.
Following is the screen shot of my storyboard.
In storyboard, it appears to occupy full screen width but in my device, the width is not full. How can I sort this out?
select your viewController and go to XCode Menu - > Editor -> select Navigation Controller ,
for example
you get the output of
it works fine for any layout patterns
firstly you have to disable size classes and auto layout in the file inspecter for your view after then set your navigation bar property like as shown in screenshot. It will be applicable for all the devices.
1- Select your element.
2- Click triangle button at bottom right.
3- Click Add Missing Constraints
use autoresizing selecting your NavigationBar:-

Constraint value for navigation bar in storyboard

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.

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