bar button item segue not adding navigation bar at top of next view - ios

When I drag to the next view controller to add a segue the new view controller has no navigation bar with a back button. I thought that was the default when you add a segue to a new VC. I'm also not able to drag a navigation bar to the top of the table view controller. Am I doing something wrong? Thanks.

Maybe the problem is the kind of segue that you are you using. The Segue type should be "Show (e.g Push)". Click on the segue and in the right panel go to the "attributes inspector" (the 4th one). And here you can check the type.

A view controller like in your case only shows a navigation bar by default, when the view controller itself or one of its parents (connected by a push-segue) is embedded in a navigation controller. Obviously, the navigation controller must not have hidden the navigation bar.
So, you either forgot to put a navigation controller into play or your segue is modal and not push.

Well, it's two years since you asked your question, but when it happened to me, I realized it was because at one point, I had accidentally created my segue as a different kind of segue (a detail one, I think), but changing it back to a "Show" segue didn't actually change it's behavior. When I found the segue in my storyboard xml, it was listed as a "Show" segue, but with a different custom action that suggested it was going to do something completely different.
Anyhoo, deleting and recreating the segue in Xcode fixed it. I probably could have also deleted that custom action in the xml file, too.

Related

Back button does not show up in navigation controller

I have added a show segue from table cell in one view controller to another table view embedded in a navigation controller. When I click on the cell in the first view the segue works as expected and brings up the new view. However, the "Back" button (with the title of the original view) does not appear in the navigation bar.
I searched SO and found a number of such questions asked in the past (both for Swift and Objective-C). Most of them suggest that the first view needs a title for this to work. I do have a title. I even added one programmatically, just in case. That did not help. One of the answers suggested to add an identifier to the segue; that didn't help me either.
How else can I debug this issue?
It seems like the problem is that you are pushing into a totally new navigationController, remove it, and make segue dirrectly into the new view Detail itself, they have to be in the same navigationController to work
Verify you are not hiding backbutton in destination controller...
I had a left bar button item in storyboard removing the button, back button showed up.

Xcode / Swift: How I implement a back button?

I just started with Xcode and Swift.
I try to build my first little App for iOS. But now I have the problem, that I don't know how to implement a the back button, so that i come back to the view before.
My Storyboard look like this:
When I open the A-Z view, I want to display the Back Arrow, which turn me back to the Item 2 view.
To open the A - Z view I connect the button "Medikamente A - Z" with the Navigation Controller.
When using storyboards the back button is usually implemented with unwind segue.
I usually like to follow raywenderlich toturials on UI related topics, like this - http://www.raywenderlich.com/113394/storyboards-tutorial-in-ios-9-part-2
It include a detailed example of how to implement back button in storyboards. Quoting from it -
Storyboards provide the ability to ‘go back’ with something called an unwind segue, which you’ll implement next.
There are three main steps:
1. Create an object for the user to select, usually a button.
2. Create an unwind method in the controller that you want to return to.
3. Hook up the method and the object in the storyboard.
When using UINavigationController, whenever you push to a new ViewController the back button will automatically appear, so you can jump back to the previous View Controller.
So it's works like:
UIViewController -> UIViewController -> UIViewController
A back button will appear on the last 2 so you can pop back the the previous ViewController.
You don't have to do any additional coding for the back button to appear, it'll do it on its own. I hope this clears it up. Let me know if you have any questions.
To implement a back button, your root view controller has to be a Navigation Controller.
The first view controller becomes the navigation root of the navigation controller.
If you want to present another view controller, you select a "Show Detail" relationship as the action for the button which should show the view controller. To do this, Ctrl-click and drag from the button to the destination view controller and select "Show Detail".
I had the same problem, even when on the storyboard the back button was visible at design time.
I deleted the segue, and recreated it with "Show" instead of "Show detail". Changing the segue to "Show" had no effect. I think this is a bug, so if you miss that back button delete and recreate the segue.

Navigation Bar not selectable in Show Segue, Xcode 6.1

There are 2 View Controllers in my storyboard, VC_A and VC_B
I have embeded a navigation controller in VC_A which is a Table View Controller, I then control drag the Prototype Cell into VC_B to create a segue. If I select "show" in "selection segue" then in VC_B I can see the outline of the navigation bar but I am unable to select it or add any bar buttons to it, it also doesn't appear in the hierarchical view.
However if I select the "push (deprecated)" option when choosing the type of segue, I am able to select the navigation bar in VC_B and add buttons to it, it also show up in the hierarchical view as a Navigation Item.
The only work around I can find is to choose show, then change the segue to push(deprecated) in the Attribute Inspector so the Navigation Item will show up in the hierarchical view, then change the segue back to show. But I am worry that this might cause problems further down the line.
Is there a way to add a Bar Button to VC_B's navigation bar without using the work around?
Just drag the "Navigation Item" from object library to the navigation bar and it should work as expected. You can make changes as you like and it works exactly like in Xcode 5.
Interestingly, when you first time made the connection b/w your table view controller and view controller using Push you can start editing the navigation bar without a problem (e.g put bar items onto it).
Then delete the connection between your table view controller and view controller (but do not delete the nav bar items you just added), then re-connect the two controllers by using segue Show, you will see the navigation bar works just like segue Push now.
Hope it helps
I think the way you do it (going through the deprecated push) is not wrong even though there's another way. In fact, when you turn the Segue into a push, you get a Navigation Item out of it.
So all you have to do is add a Navigation Item to your View Controller and that'll do the trick:
This seems Xcode bugs.
In my case, i am re-create segue by this sequence:
Delete existing seque. (I am using "Action segue - Show")
Drag new segue with "Non-Adaptive Action Segue - Push (deprecated)"
Delete segue no.2
Re-create/connect "Action Seque - Show". (No.1)
Done
Now, i can edit navigation title and add custom navigation item button as usually.
I am using Xcode 6.4, and minimal target iOS version 7.
In your viewController :
self.navigationItem.title = "Second VC"
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Play, target: self, action: "playFunction:")

Proper way to segue between two simple View Controllers in iOS 7

I'm mainly from a C# background, so the workflow for iOS is a bit unusual for me, at least for now.
I was having a problem having simple segue from a main menu, to a another menu/work area, and then with the ability to go back to the main menu.
For a test, apparently I did something wrong.
I didn't write any code for this test to exhibit the problem.
What I did was just,
create a new single-view app
drag an additional view controller onto the work area
drag the start arrow to the new view controller (so it becomes the initial view, same thing as checking the checkbox to set it as the initial view)
added a button to each view controller
Ctrl + clicked and dragged the buttons to the opposing view
for the segue type, I chose "replace"
now the program crashes if I hit the second button to go back to the "main menu" (green view controller in this example)
So what am I doing wrong? Do I need to add some form of delegate or something?
I did find this, though it present fewer segue options in the tutorial than what I have.
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/SecondTutorial.html
These are the options I have when I Ctrl + Click from a button to another view
-Push
-Modal
-PopOver
-Custom
-Replace
"Have you embedded a navigation controller? You need to go to editor->embed in-> Navigation Controller. You need a navigation controller for push segue. – Kaushal Bisht"
This solved it for me. Now I'm just going to work on replacing the navigation bar with custom UI controls.
Thanks everyone! :)

ios storyboard tabbar > ViewController > TableView

I would like to create the following navigation
I have a tab bar program build with storyboard
and I have a View controller with buttons
when I click a button A navigation controller is called
Right now I have made all the connections and everything works fine but..
in order to create the change from the button to the table view I am using modal segue and that removes my tab bar.
I know that push will not work cause its not a navigation but how can I work this out?
I had the same problem but I realized that the best option is do it using a push segue. It's the best option because when you have a table view into a tab bar item it's more usability, it's what customer want. I'm sorry for not solution your problem but I strongly recomend you to use push.

Resources