xcode: can't see in storyboard a navigation item - ios

I have added to my tableView with navigationController a bar button with text "Start!".
But I can not see it anymore in the storyboard.
In my build I can see it:
I think this is also the reason for this error log message:
pushViewController:animated: called on while an existing transition or presentation is occurring; the navigation stack will not be updated.
What can I do to make the bar button visible again?

The tableviewcontroller is covering the navbar in your storyboard. Check the properties in the storyboard and verify that your tableviewcontroller is inheriting his geometry. (setting is called inferred)

Related

Swift: how to make tab view controller button not show?

Ok, I have all my view controllers managed by a tab bar controller, and obviously when you connect in the storyboard the relationship between the controller and the Vcs as "view controller" a button appears on the tab bar. These are then accessible via the tab bar controller.
My problem is I need to have one VC be the in view controller array but NOT BE SHOWN IN A BUTTON on the tab bar. It should not be accessible to the user, but I need to be able to switch to that VC in code with selectedIndex
I do not know how to do this. I have tried disabling the button and doing
self.tabBar.items?[3].accessibilityElementsHidden = true
But the button is still there on the tab bar. How can I have the VC in the array of the tab bar controller but not shown in a button?
This is not possible using the UITabBarController as is.
Not 100% sure on why you need to have a VC in that array but never visible on the bar, consider subclassing UITabBarController if thats the case.
Changes to the viewControllers or items property of a UITabBarController will encourage iOS to reload the Component and hence why you are seeing the VC in the TabBar.

Navigation Item not visible in interface builder after adding segue

I have custom UIView, that uses .xib file. I'm adding this view in storyboard inside view controller. After that I added TapGestureRecognizer to it. Then I attach segue to tap gesture recognizer (no code needed to perform segue from custom view this way).
Problem is, navigation Item is not shown in interface builder. When I build and run app, navigation is on screen and everything works like expected.
When I add segue from VC to VC, navigation bar is shown in interface builder. Why I'm getting such behavior?
That seems like a bug in Interface Builder to me.
I see two possible workarounds for this situation:
Wire the segue from ViewController to ViewController. Give it an identifier. Call it programmatically with performSegue(withIdentifier:sender:) in an #IBAction for your Tap Gesture Recognizer. The downside of this is that you need to add code.
Add the Navigation Bar to your ViewController by setting Attributes Inspector -> Simulated Metrics -> Top Bar to Translucent Navigation Bar. This allows you to see the Navigation Bar in Interface Builder. The downside of this is that you need to do this for every ViewController down the chain.

Hide UINavigationBar 3D touch

I am trying to 3D peek and pop items in a UITableView. Everything works fine, except the target ViewController has a UINavigationBar which also shows.
I added my UINavigationBar to my ViewController code through Interface Builder and set self.navBar.isHidden to true which hides the UINavigationBar, but it leaves empty space equal to the size of the UINavigationBar.
Does anyone know how to hide the UINavigationBar properly?
Note: I am not using a UINavigationController, I simply added the UINavigationBar to my ViewController by drag/drop.
the target ViewController has a UINavigationBar which also shows
Use a real UINavigationController plus UITableViewController (as its root view controller). This is an excellent way to have a navigation bar even if you never intend doing any navigation.
Here's a big advantage of doing that: You don't even need to hide the navigation bar when you peek! Use the UITableViewController alone as the peek navigation controller, and the UINavigationController when you pop. Thus, the preview won't have any navigation bar but if the user presses all the way and you do the real transition, the new view controller will have the navigation bar. Remember, no law says that the peek view controller must be the same as the pop view controller!

How to add buttons to navigation controller visible after segueing?

I have set up a view controller in Storyboard which is embedded in a navigation controller. In this nav controller I have checked Shows Navigation Bar and Shows Toolbar and enabled a navigation bar and toolbar in Top Bar and Bottom Bar respectively in Simulated Metrics. I then "Show e.g. Push" segue from the view controller to another view controller. On both view controllers I've set up Simulated Metrics the same way, so both the navigation bar and toolbar are visible on all three controllers.
The problem is, I can add bar button items to the first view controller to both the navigation bar and the toolbar, but I cannot add a bar button item to the navigation bar on the second view controller. When I drop a button on the navigation bar, it's added to the toolbar instead. And I cannot double click the nav bar to add a title. In the outline I see there is no navigation item on the second view controller, but it is there in the first view controller.
I can probably add buttons to the navigation bar programmatically, but I want to do this visually in Storyboard. My question is, what is wrong with this setup, or is this a bug with Xcode?
For XCode 6, the UINavigationItem for the 2nd view controller onwards is not added automatically on the View Controller Object inside the storyboard. You will have to drag the UINavigationItem onto the Navigation Bar for that view Controller Object before adding UIBarButtonItem on top of it.
I am not sure why it is designed that way. I only discovered about this a few weeks ago.
If you have a ton of view controllers and very little custom auto-layout stuff in place, you can disable size classes, then re-enable it will add all missing nav bars across your storyboard.
Obviously not recommended if you have a ton of custom auto layout stuff linked up.
If you have just a single UIViewController that's missing a nav bar, just drop a UINavigationItem onto it.
If you're using Xcode 7 beta 4/5, try restarting Xcode it solved the issue for me
I just bumped into this issue and it seems to be affected by the segue that shows the view controller.
If "Kind" setting in segue is "Show (e.g. Push)", it's not possible to drag the item to top right corner. However, if you explicitly change "Kind" setting to "Push", this can be done.
Edit: actually I just noticed that "Push" is deprecated. Not sure what Apple is thinking here. However, you can just change it back to "Show" after adding the button and it seems to work :D
For second view controller in hierarchy, you can setup title in attributes, without adding "navigation item"
I think it is a bug. I had the same problem.I fixed this problem by disable the size classes, then enable it.
You can disable and enable the size classes in Interface builder doc.
It's very simple. You just need to use navigaitonItem first as the holder of the buttons and then you can add barButtonItems on top of that.

Custom segue causes navigation item to disappear

I'm using custom segues with no animation because I don't like the animation of the default segue. The problem is that in the storyboard, when I flip the segue style from Push to Custom, the view controller's navigation item disappears. Now, it seems that the navigation item still works even if the segue is set to Custom, but that means constantly flipping back and forth between Push and Custom when changes need to be made.
Is there any way to use a custom segue and still have IB access to the navigation item?
Yes, select the view controller and open the attributes inspector. Then change the "Top Bar" from "Inferred" to "Navigation Bar". That should keep the navigation bar displayed.

Resources