Can I use a single navigation controller to the multiple storyboards? - ios

I am using two storyboards Main and StoryboardA. For Main.storyboard i have embedded a navigation controller. From Main.storyboard i need to go the storyboard StoryboardA. So for acheiving this i have given a storyboard reference. But the problem is i am not getting the back button on the StoryboardA . It seems the StoryboardA is presenting itself instead of getting pushed. Please see the below image: So My question is do we need to use another navigation controller for StoryboardA?
Main Storyboard:
Second Storyboard:

I seem to have found a solution mired in all of these solutions for old versions of iOS and Xcode. In short, in your second storyboard, mark your first view controller as "Is Initial View Controller", not the navigation controller.
Your navigation controller will remain and still point to your first view controller. I wonder about downstream issues yet to appear but others seem to have had success.

Have you added segue as push ? On control click - > Select segue type as Push .It should work fine.

You can use a RootViewController for many StoryBoards but you can use only one Storyboard for a NavigationController

Related

How to link a separate storyboard to each particular tab in uitabbarcontroller?

I have an app which has 5 major user flows..each flow is a few screens linking to each other...so each flow warranties its own storyboard. Each storyboard starts with a custom view controller that is embedded in a navigation controller. So far so good.
Now all of this is "stitched" together via a UITabBarController. This is the most default UI design ever known to iOS.
But turns out I don't really know how to link from tabbarcontroller, which is in its own storyboard (that is set as the main one on code project) to any of the other storyboards.
This problem looks so! simple, so I think I am missing something utterly obvious, but I just can't figure out how to do it.
So how do I link from tab bar controller in storyboard 1 to the initial view controller in storyboard 2 when a tab is tapped?
You should do this in code. You can have the tab bar controller (tbc for short) and the controller in the first tab in the app's main storyboard, and in the app delegate, instantiate the other controllers using instantiateInitialViewController. Create a mutable array by copying the tbc's viewController array, add the other controllers you instantiated to it, and then set that array as the tbc's viewControllers array.
You have to add your viewcontroller programmatically in tabbar.

'Show' segue in Xcode 6 presents the viewcontroller as a modal in iOS 7

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.

TabBarController in NavigationController does not show TabBar in viewControllers

I have a UITabBarController to whose controllers I would like to attach navigation. So I inserted the NavigationController as the entry controller, and the tabBarController as its root. All seems working fine, but for the tabBar. Basically it does not show, albeit the StoryBoard I attach seems to say differently. I also attach the Account Screen not showing any navigation bar nor, of course, any back button.
Thanks,
Fabrizio
Just a quick answer. I think you should put UINavigationController inside the TabBarController instead of the other way round. It will solve most of your problems.
Steps: Editor -> Embed in -> Navigation Controller
See the below screen shot on how to add a Navigation Controller to a View Controller.
You are following wrong approach, IOS does not allow you to use tabbarview controller as root of navigation controller, it always display black screen. I have faced same problem and as a solution i have added navigation bar after tabbar controller. Yes it becomes difficult to manage, but you can use that way and it will work.
If you use programmatic approach instead of storyboard then it is possible, see this link
Even you can try from Editor option of XCODE, select tabbar controller you have added from storyboad then go to Editor->Embedded in, you will see that navigation bar controller is disable.
This is also give you idea that it will not work.

How to build navigation controller from existing view controllers drew in storyboard?

I have built some view controllers in storyboard like in the picture below
I already implemented the data inside them, modal segue is used for transitions in between. Now I just realise when I push "back" button, previous view won't be properly loaded. I figure I should switch to navigation controller and add those controllers in stack instead. But I don't know how to go from where I am now.
I think I should make changes programmatically because I found building navigation controller in storyboard won't have much variation in UI design (at least I don't know how to implement existing pages in that way). So what should I do to implement programmatically? Please help me, thanks!
Select Category View Controller and go to menu: Editor > Embed In > Navigation Controller. Then change segues style from Modal to Push.

Switching UINavigationViewController to UITabBarController with Segues

I am changing my app to use UITabBarController instead of UINavigationViewController. I replaced controllers accordingly and app launches with tabs successfully. Later in the code I came across some difficulties using segues where lines like
[self performSegueWithIdentifier:#"ImageViewController" sender:self];
won't work producing error
"Push segues can only be used when the source controller is managed by an instance of UINavigationController"
When I embedded UINavigationController into the initial FirstViewController, line above worked fine. I need that line to switch between views and pass some data to another view controller.
The problem is that using segue identifier to go to SecondViewController hides TabBar navigation (unless I wrap SecondViewController in UINavigationController again and so on). That is not the solution.
Question: How to use UITabBarController and still take advantage of segues while keeping tab navigation visible?
"Push segues can only be used when the source controller is managed by an instance of UINavigationController"
Sounds to me like you are using a push segue somewhere outside a navigation controller. Try to select all "segue bubbles" in interface builder that are not inside a navigation controller:
and check the segue's style in the right pane:
If the style is set to the value push as shown above change it to modal or custom:
There is something wrong with your connections. If you are using interface builder (storyboard) then your connections should look like this. See pic
Notice you are missing UINavigation Title headers. Also the gray area below on each view controller means that space is reserved for images for UITabBarController
Another problem is your UIToolBar. Looks like its sitting on top of where UITabBar will be displayed. That may/may not get your app rejected by apple since you already have a UINavigationController and UITabBarController. If you need more buttons/options on that page make them UIButtons instead.

Resources