Interface Builder Scaling? - ios

I've noticed in two different projects over the past few days that distances aren't lining up between IB and the actual app. For example, in one application I have a MKMapView. In IB, it is aligned with the bottom of a UIImageView, however when deployed on device it overlaps by about 20pts.
What's the issue? Elements are getting pushed up and down the screen. Using a tab bar interface. The tab bar is present on the bottom of the NIB, so I don't think it's a resizing issue. Help?

The tab bar should be a "simulated metric", not an actual tab bar on the screen. Select the main view itself (click the border), and open the attributes inspector (Command-Option-4). Under Simulated Metrics, select Tab Bar from the popup for Bottom bar.
The other possibility is when rotating—set your structs and springs correctly. You haven't mentioned rotation though, so I think it's the first answer.

Related

Implementing Safe Areas for Tab Bar Controller and iPhone X

What I'm trying to do: place the tab bar at the bottom of the iPhone X display where it belongs, and also put the navigation bar at the top of the display.
I've been trying to accomplish what I thought would be a straightforward task of using Safe Areas in the storyboard to position the tab bar near the bottom of the iPhone X's display. I'm missing something fundamental.
I've read a lot of writeup about how to do this, including this one. It includes a screenshot of a tab bar control scene that looks like this:
But I can't create a view inside my Tab Bar Controller to put my tab bar item in, as the article mentions. It's my understanding that I'll use the safe area of the view that should contain the tab bar item. But it won't let me put a view anywhere except outside the Controller view. I've tried using "embed" - but all options are greyed out.
Same goes for a navigation controller to move a navigation bar to the top of the display.
The funny thing is that IB renders it in the right place, but on my device, the tab bar is way above where it should be (and the navigation bar way below).
I have "Opens in" set to "Latest Xcode (9.0) and Builds for iOS 11.1 set in the scene's "Interface Builder Document", and "use Safe Area Layout Guides" is checked. I'm not using any custom classes for my tab bar controller or tab bar. I'm using XCode 9.3 and iOS 11.3.1
What's the simple thing that I'm missing? Thanks in advance.
The article explains how to adapt your app if you're using a custom navigation bar or a custom tab bar.
If you're using the standard navigation bar or tab bar then you have to make sure it's top or bottom (depending on the element) constraints are connected to the superview and not the Safe Area layout guide. UIKit makes sure these elements are correctly rendered with spacing at the top or bottom on an iPhone X device. Check out this screenshot for clarification.

Using Autolayout and universal storyboard super view is not taking the full screen?

I am developing an iOS application using Universal Story board and autolayout. The base views of my view controllers are leaving a space at the bottom and are not taking the full height of the screen. What could be the reason behind this?
Go to property area in the storyboard and choose your main view then select all the lines which is available in that area. then it holds the full view of the page.
It looks like your view is taking up the whole screen but is hidden behind a tab bar.
This will happen when you include them inside of a UITabbarController. The reason they reach down underneath the tab bar is because it is translucent (you can see a blurred version of the view through it).
This tutorial from Ray Wenderlich gives a good example and explanation of how to set this up in a storyboard.
https://www.raywenderlich.com/50308/storyboards-tutorial-in-ios-7-part-1
Actually the "Show Toolbar" option for my navigation controller was checked. The space at the bottom was taken by the toolbar.

How to use Bottom Bar together with SpriteKit?

I created a sprite kit project and was trying to add a bottom bar to it. However, after selecting the "opaque toolbar":
Game View Controller > Attribute Inspector > Simulated Metrics > Bottom Bar > Opaque toolbar
While the toolbar does appear in Main.Storyboard, it does not show up in the simulator.
Whats going on?
You are adding a "Simulated Metrics", this will only add a bar in the Storyboard (it just helps the developer to see graphically how it should show in the real device, and helps with constraints).
You need to add a UITabBarController in the storyboard. (you can drag and drop and you will see how it works)

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.

Navigation bar View Controller is twice the size as others

I have a multiple View Controllers embedded in Navigation Controller and one of my navigation bars is twice the size(extends down twice as much) as every other one. I want all of these bars to be the same size, but can't find anyway to change the size in Inspector. There are no bar buttons on this Navigation Bar. Any ideas for a quick fix w/o having to rebuild this VC?
Thanks
Default UINavigationBar have a height of 44 points and it can't be changed. I think you have a constraint issue: select your wrong sized UINavigationBar and on the top right corner, in the "utilities", select "size inspector". Then, have a look at the severals constraints, edit and/or delete some.

Resources