Xcode black bar on top of view controller after connecting segue - ios

I have a problem with my Xcode project. The problem is that when I link one of my view controllers up to another with a segue a weird black bar appears on the top. Here's a video of that problem.
https://imgur.com/a/ctttXlZ
Does anyone know what might be causing this?

This is because the segue to the second ViewController is a "show", and the second VC will show like this:
If you want this VC to be full screen, click on the segue you created, change the "Kind" property to "Present Modally", and the "Presenttion" property to "Full Screen":

Related

How to go to tabbar item from an external view controller

Im stuck with a problem me and a friend of mine are building a app in ios. see video.
please watch this video:
https://youtu.be/SHrBF6h8Nso
The problem is when we are done with the workout and we get to the finish workout screen and we click on the profile button it goes to the workoutOverview Screen. But we want it to go to the profileOverview screen.
We try to achieve this with this line of code :
self.tabBarController?.selectedIndex = 1. // this results in segue to workoutOverview instead of profileOverview, no matter what index we use
But finish workoutOverview is not part of tabbar controller or the navigation controller that we have.
the second problem
When pressing the cancel button (cross) we would like to pop to the first viewcontroller (muscleList) but without losing the tabbar!
see how our storyboard is connected in the picture:
Question:
How to go back to profile view controller in the tabbar controller?
How to show view controller with tabbar controller when click on the cancel button?
If anyone have a idea it would help us a lot.
xCode has a bug with the show segues. Change all "Show" segues to the deprecated "Push" segues and build and compile. Than change all back to "Show" again, build, compile and it works now! All viewcontrollers will be added to the stack.

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.

When using Show instead of Push, which is deprecated, with UINavigationController, the VC being shown doesn't have navigationItem

Alright, here is the deal.
I have a UINavigationController which has a root VC. From this root VC, you can show another VC, and from there, another, and from there, another.
The problem is that I'm running into what I think is a bug in Xcode.
In the below image, you see a button in my rootVC navigationItem that I use to segue with Show to display the second VC. You can clearly see the Navigation Bar, but when I try to drag a UIBarButtonItem into it, I can't and the reason is because if you look at the menu on the left, you'll see that there isn't a Navigation Item to drag the button into!
If I instead use the segue Push to display the second VC, I get a navigationItem... but apparently Push is deprecated.
How do I mitigate this?
Edit: I guess I can just drag in a UINavigationItem into it... but I really don't know if I should. Would there be an empty UINavigationItem underneath that that I just don't see in storyboard but is actually there?
The navigation item is not created automatically on the second view controller, you're right. Drag a new navigation item into the second viewcontroller's bar, and you should be good to go.

iOS navigation has no navigation item

In the current version of Xcode a few things seems to work a bit different.
I have a little problem working with a simple navigation. This is what I do:
I have a Storyboard with two scenes.
I connect the scenes with a segue of type "Show".
(In the past I did use "Push" but that is deprecated now.)
I select the first scene and choose "Embed in Navigation Controller.
Now both scenes will get a gray bar at the top but only the first scene will also get a Navigation Item.
Only for the first scene I am able to edit a title attribute and only for the first scene I am able to add a Bar Button.
Navigation itself works fine. The title of the first scene is the text of the Back-button in the second scene.
Why has the second scene no Navigation Item?
Is it because of the segue type?
Yeah, its a bug in Xcode from version 6. If you want Navigation Item in second view controller too, then there is a hack to get it.
Change the seque type from show to push. Now Navigation Item will appear in second VC too. You can again change the seque type from push to show, the Navigation Item will still present in second VC.
IB will automatically add UINavigationItem to root view controller of your UINavigationController.
To the rest of your controllers in navigation flow you need to add UINavigationItem manually from IB Object library.
What I do is to drag a navigation item from the list of controls to the top, gray bar on the second ViewController. Then you can drag other items such as bar buttons onto it, as well as being able to edit the title.

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

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.

Resources