I am trying to use UITabBarController in swift 4.2: https://developer.apple.com/documentation/uikit/uitabbarcontroller to navigate between 2 views, lets say ViewController1 and ViewController2 , each of these controllers being embedded in his own navigation controller. I am using swift 4.2 and deployment target is IOS 12.1. (Image with storyboard and controllers)
But it seems the default behavior is that to go to another tab you need 2 clicks(taps) as described also in Why i need to tap tabBarViewController item Twice to navigate to different View Controller - iOS
At first I thought it is something that I am doing wrong, but also trying the template provided by the IOS team for the tab bar it seems that the workflow is the same.
I created the UITabBarController from the storyboard. I also tried creating a custom tab bar class but did not manage to make it work. If I click once on ViewController2's tab, the viewDidLoad() and viewDidAppear() for ViewController2 are being called but the UI is not refreshed. After clicking anywhere in View or try to scroll the View is refreshed with the correct ViewController2.
Can you help me with this issue please? How can I make UITabBarController respond to a single click for a tab?
I'm following the "personality quiz" guided project from Apple's book "App development with Swift".
The guide had me create several view controllers and a bunch of labels and a buttons so far. Then it came to creating segues. TLDR of the instructions is:
Control-drag from the button in the first VC to the the second VC and create a show segue.
Control-drag from the VC icon above the second VC to the third VC and create a show segue. Embed the second VC in a Navigation Controller. Create a modal segue from the first VC's button to the Navigation Controller.
Now, here
is the result as shown in the book (last VC missing from in the frame)
on the other hand is what I ended up with.
What could be the problem?
Thank you.
EDIT: Yes, I am using Xcode 11 while the guide shows Xcode 10.
To further explain my actual problem - If I understand it correctly, I ended up with a "modal presentation" while the book wants to have a "right to left push".
The screenshot from the tutorial is not taken in Xcode 11 (Probably Xcode 10). You seem to be using Xcode 11, which shows the VCs as if they are in iOS 13. Xcode 10 shows them in iOS 12, so of course they are going to look different.
Don't worry if your actual result doesn't exactly match the result shown in the tutorial, unless it doesn't actually work. If it's just aesthetic differences like this, it is very normal because the tutorial is using a different version of Xcode. The important thing here is that your first VC should present a second VC that is a UINavigationController. If you run the app and it does present it, then it's working correctly. iOS 13 just presents it a little differently than iOS 12.
If you want to achieve the full-screen VC look, select the segue between the first VC and the navigation controller, and change "Kind" to "Present Modally" and "Presentation" to "Full Screen".
I'm havig this navigaton bar at the very beginning of my project, I'm hidding it at connection and then displaying it later on.
My sotryboard began to get huge so I've decided to put the parameters views of my app in a second storyboard.
The second storyboard begins with a view (that I'm displaying using "Presentr" library) which has already no access to the navigation bar from the first storyboard.
I think that the storyboard reference is somehow destroying my navigationController.
What am I doing wrong, and what should I do to correct it ?
My issue was because of library "presentr". Somehow when I'm using this library to dsplay a VC (no matter how it's linked into the storyboard), the VC loses the hierarchy with the navigation controller.
Hope it'll help
I am new to iOS development and have not tried this programmatically yet. I would prefer to get this working in a storyboard.
I'm following this somewhat outdated tutorial from XCode 4.5 in XCode 6.1 to create a series of views connected by one navigation controller.
http://youtu.be/rgd6mCuzlEc
Once I create the second view controller, I am unable to double click the navigation bar to change the name and I am unable to add a bar button to it.
I have a Segue going from bar button "Item" from view 1 to 2. Notice in the "View Controller Scene" there is no navigation item. If I add any elements to the view controller they fall under "View" and not under "View Controller", unlike view controller 1 where it falls under "one".
Is this a limitation on XCode? Am I using the wrong Segue (Show)? Is there a hidden setting or customization I'm missing?
I actually have this working for 2 view controllers and failing the 3rd in a separate project but I don't know what I did to do that so I'm pretty sure it's possible I just cannot reproduce..
EDIT: Workaround Instead of the new adaptive SHOW segue, use the deprecated PUSH segue, add the bar button items, then change back to the adaptive SHOW segue.
Try adding a Navigation Item to the controller and it should work properly
I have two view controllers in my iPhone application (built with swift) built with Xcode 6.1 and uses storyboards.
The first view controller is embedded in a navigation controller in the storyboard and the segue for the second view controller is a 'Show' segue.
When the application is run, it properly shows the transition as a push in iOS 8.x, but in iOS 7.x it appears as a modal without the navigation bar.
My application requirement is to show the transition as a push regardless of whether it's iOS 7 or iOS 8. Any ideas to get this working as push in both versions of the iOS?
I saw a related post where this issue is mentioned, but could not find a solution to the problem: Adaptive segue in storyboard Xcode 6. Is push deprecated?
Any help is appreciated...
Thanks
This solution is different from the others in the following ways:
It includes a method to examine and verify the issue
The cause of the issue is traced to the source (a change in the segue type)
The solution is very simple (delete and recreate a new segue)
Please note the requirements in the text
I just gave a very detailed SO answer that fully explains what is happening and why, but the simple solution is you can delete the Segue that is not pushing and then recreate it on the storyboard. The reason is that there is likely a broken bit of xml in the segue (see extended answer for example/instructions how to confirm this issue).
After you confirm that you have at least one UINavigationController within the view hierarchy, be sure that the segue is NOT a manual segue and does NOT have an action associated with it (by viewing the segue in the storyboard as Source Code). Delete the existing segue and then Ctrl-drag from a UIView/UIControl to the target view controller and if custom action is needed intercept the call to destination controller in prepareForSegue.
Also to confirm that this solution works for you please do the
following:
Verify that your initial view controller (with the arrow on it) is a
UINavigationController and that it has a normal content view
controller as it's root view controller. (or that you embed your
initial view controller inside of a UINavigationController)
Read my extended comments on an earlier response to a very similar question (linked above).
It's possible that you have assigned the Initial View Controller to your UIViewController instead of the UINavigationController. Also, select your UIViewController and check that the "Is Initial View Controller" option is unchecked.
Here is the workaround for that. It looks like a bug in Xcode for iOS 7. You need to create a dummy UINavigationController and link all your free UIViewControllers to this navigation controller. Worked for me.
For me, my storyboard lacked a navigation controller. I am creating the navigation controller programmatically, which works fine in iOS8, but not iOS7.
SOLUTION
In your storyboard, select the main view controller and in the Xcode menu, choose Editor > Embed In > Navigation Controller.
Select the new navigation controller, and in the attributes inspector on the right, under View Controller, make sure Is Initial View Controller is checked.
Run the app. Should be fixed now.
I believe this is a bug in Xcode 7.2. In order to workaround, you can create a "Push (deprecated)" segue and then in the Storyboard editor, select the segue and change it to Show(e.g. Push)
I have had this exact issue with "Show (eg. Push)" for ages and I have just figured it out whilst trying to push a view controller onto a navigation controller that is in a Popover. It seems that the context of the called View Controller is the problem. So this is how I resolved it:
On the View Controller performing the Segue, check the "Defines Context" property in the Storyboard.
In the called View Controller, set the Presentation property to "Current Context".
I ran into this problem and the only solution I found that works for me is to use the deprecated 'Push' segue.
I am using XCode 9 with Swift 4. Note this version came out yesterday (September 20th).
For me this was just a caching bug. I had to choose "Present Modally", run the app and then choose "Show (e.g. Push)". Now everything works fine.
Basically the answer of Jomafer is partly correct. The controller which you are pushing needs to be preceded by a UINavigationController. You dont really need to push the UINavigationController at all. As long the storyboard knows its within a UINavigationController, all is well.
When a "Show" segue comes up as a modal segue in testing it is usually one of two problems:
The first view controller is not inside a navigation controller.
The storyboard XML is corrupted.
The solution to #2 is usually to remove and replace the segue, and it should correct itself. Sometimes just switching to some other presentation style, running, and switching back to "Show" fixes it.
This can also happen to "Show Detail" segues, and it can be more insidious.
Example:
I have a series of view controllers arranged in a UISplitViewController. They have segues Show->Show->Show->Show Detail. The last segue kept coming up modal. I tried everything to fix that last segue. The problem was that the upstream Show segue had been corrupted into a Show Detail segue (even though the storyboard still said it was a Show segue). I had been testing on iPhone, and I did not discover the real problem until I ran it on the iPad simulator. The segues were now Show->Show->Show Detail->Show Detail. On the iPhone the third segue looked just like a Show because it collapsed onto the navigation controller. However, it is still the detail view controller, and you cannot have a Show Detail from a detail view controller, so the OS does what it can to get your view controller on screen and displays it modally.
Lesson 1: Always test your UISplitViewController on iPad to make sure the segues are doing what you think.
Lesson 2: If your segue is coming up modal unexpectedly, check the upstream segues for corruption as well as the segue in question.
Problem in my case was that I created Show (e.g. Push) segue before putting ViewController as rootViewController of UINavigationController. In other words I didn't have UINavigationController.
Then I deleted seque, added UINavigationController and added seque again and it worked. Tested on Xcode 9.0.1 / iOS 11.0.3.