UITableView within a UINavigationController within a UITabBarController, unwanted bottom toolbar - ios

I'm having trouble with this hierarchy producing an unwanted empty UIToolbar directly above my TabBar.
I've tried using the inspector in XCode to figure out where it's coming from but the view heirarchy is not clear about what this toolbar is nested within. This seems like it would be a common problem but I'm not having any luck searching for solutions.

Check your storyboard in the interface builder, under the Attributes Inspector > Simulated Metrics > Bottom Bar. Without knowing more about your project, it should be set to "inferred" (as in, inferred from the Tab Bar navigation controller).

Related

How to connect Xcode Storyboard's "Simulated Metrics" toolbar to an actual IBOutlet UIToolbar?

I'm hitting issues when attempting to design a UIToolbar Accessory View via an Xcode Storyboard.
When I drag a UIToolbar object to the top margin of my View Controller, the item is added to the left pane and I am able to connect it to my class's IBOutlets. It appears correctly when I run the app.
However, the toolbar is not visible anywhere on the storyboard. I thus lose the visual editing benefits of using Interface Builder in the first place. The bar button items are only visible in the left sidebar.
I have seemingly gotten around being unable to see the views in the IB canvas by using the View Controller's "Simulated Metrics". Now I can see a Toolbar in the Storyboard.
Attributes Inspector > Simulated Metrics
Set "Bottom Bar" to value "Opaque Toolbar"
Drag Bar Button Items into this Simulated Toolbar
However, when I run the app, this "Simulated Toolbar" is not visible.
I am unable to link the simulated toolbar to an IBOutlet via the Connections Inspector
I have not found a way to link the "toolbar object" (first image) to the "simulated toolbar" (second image).
My main goal here is to see a visual representation of the Toolbar in the Storyboard. Is this possible?
Simulated metrics are just that -- simulated. They help you to visualize your design, but the artifacts won't necessarily show up at runtime short of some other mechanism. The toolbar that you created in the storyboard is there at runtime but not added to your view. That's why it's up in the header of the scene.
The standard use of UIToolbar is to allow a UINavigationController to manage it. So there is a toggle in InterfaceBuilder's Attributes Inspector pane when a UINavigationController is selected.
From there you can add UIBarButtonItems as needed, and hook them up to IBOutlets in your code. No need to hook up the toolbar to an IBOutlet; you can get it from your UINavigationController's toolbar property at runtime.
See the Apple docs.

Storyboard / Navigation Bar issue in Xcode

I'm experiencing a bit of a weird issue and I'm hoping someone can point me in the right direction.
In Xcode, using storyboard, I have a view controller that inherits a navigation bar. This is working fine. Where the issue is is that when I add an element to the view controller (ie, UIButton, UILabel, etc) and run the application on my phone, the Y positioning of the element is off by the amount of the height of the navigation bar.
Let's say I wanted to have a UIButton DIRECTLY BELOW the navigation bar, I would have to move it UNDER the navigation bar, to the very top of the view controller on the Storyboard. On my phone it would be directly below (Y positioning) the Navigation Bar.
I'm fairly new to iOS development, so I'm not even sure where to begin. I tried enabling / disabling Auto Layout, which didn't change anything.
Try this:
Click on your view controller, in the Attributes Inspector uncheck the "Adjust scroll view insets" option.

UITabBarController in storyboard hides content of UITabBarItems

I am a beginner using storyboards for iOS. I have been using the tab bar controller to show my content.
When I first implemented the UITabBar I could see all the icons at the bottom of the UITabController in storyboard and I could see the UITabBarItem at the bottom of each UIViewController. Why is there now a blank grey bar? I can't seem to change the content either in storyboard. I tried adding another UITabBarController but got the same problem, it also has a dark grey bar at the bottom. However when I run the app all the icons appear. How do I fix this so I can see the UITabBarItems in storyboard or should I just try updating them programmatically instead?
Showing a tab bar or not is one of the couple of simulated metrics used in Interface Builder. As such they only serve to have an idea of how your controller would look under different conditions but do not really change anything to the actual controller.
Most of the time the default Inferred option will try to deduce from the Storyboard configuration how it should look like. In your case just connect the tab bar controller to your controller through the viewControllers outlet.
In contrast, below you have some View Controller properties that change both how your controller is previewed in Interface Builder and also its actual behavior (for instance try changing Adjusts Scroll View Insets or Extended Edges).

UIToolbar not showing but it's below the self.view

I make a toolbar in my view but I can not see it.
I use Reveal.app to check out the structure of the view
I find out the toolbar exists and it's
below the view so I can not see it. How can I fix this?
Of course I use
self.navigationController.toolbar.hidden = NO;
And these my screenshot:
Thank you in advance.
The Navigation Bar you have at the top pushes all of the content 44 points down.
In you storyboard or .xib file, you should select the view for this controller and set the top bar property to Navigation Bar. This way you will be able to work in interface builder and your content will be positioned properly.
Good luck!
Edit
Select the your ViewController in Interface Builder:
In the Inspector pane in Xcode change the Top Bar value
Open your view's .xib file and select your main view of this viewController. And then choose the Attribute Inspector on the right. And in Simulated Metrics, there has an item named Top Bar. Set your top bar into Navigation Bar instead of none. I thank that will help you.

aligning UINavigationBar programmatically with other controls added through Interface Builder

If I am pushing a view controller onto the NavController, is there a way when designing this view to have the controls line up correctly?
Here's the issue I'm having, I had to align the TableView and MapView like so to get it to show up properly when loaded into the navcontroller:
This seems wrong. The mapview as you can see overlaps the tableview in the editor, but when it runs their lined up correctly. If I raise the mapview to line up directly on top of the tableview, when run, theres a white gap between the two. I realize the NavBar is pushing things down, or that's my guess.
Is there anything in the Utilities I can set to handle this?
You can manually tell the view controller to show a navigation bar in interface builder in the attributes inspector.
select your view, then in File Inspector, uncheck Use Autolayout. It may helps you.

Resources