How to show split view controller on tab bar from different storyboard? - ios

The below is my Main.storyboard and it is having tab bar controller. I wish to show a split view controller in one of the tabs of it. The splitVC is in other storyboard as shown in second picture
This is second storyboard which has a split view controller.
I am unable to show it in main storyboard using following approaches:
• Using container view: I tried to show the splitVC in container view programatically but it is throwing error saying :ContainerView must have view controller at index 1 (I tried container view as shown in first picture.)
Can anyone suggest the best way to show it on tab bar ? Or if I am doing container approach not correctly?

Hi #Divjyot Answers here might help apple recommends UISplitViewController should always be the rootviewcontroller
Here is the note from apple
You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases. Split view controllers are normally installed at the root of your app’s window. For tips and guidance about ways to implement your interface,

Related

iOS Swift How to go back from a split view to a normall view controller

I have a simple iOS app that I want to use a split view in, but I also need some normal view controllers(non Split view). So I have my story board setup like this:
Story board
I will add more views to the base navigation view depending on what they click on in the first view some will go to other standard views and one will go to another split view. as I can not add the split view to my base navigation view (get an error saying it had to be the root view) I replace the root view with the split when the button is clicked using a replace Segue.
My question is: how do I get back to the first view once I am in the splitview? can I somehow had a custom back button to the detail view title bar to go back? Or am I going about the whole thing wrong? Any help or a push in the right direction would be great!
I ran into this problem myself. Unfortunately, UISplitViewController cannot be added as a child of another view controller. I must be the root view controller of a window. From the docs: When building your app’s user interface, the split view controller is typically the root view controller of your app’s window. The way I got around this was just creating a container view controller in my storyboard: It ended up looking like this:
It's pretty basic, just adding the two view controllers as children of the parent view controller. You can control the width of each on straight in IB.

Can I have a SplitViewController inside a TabBarViewController(iOS 9.0 +)?

I have an app with UITabBarViewController as rootviewcontroller. On some tab item, I want to have a SplitViewController inside a UITabbarViewController.
So here my UISplitViewController will become a childViewController for TabbarVC.
Will this be allowed? Are there any Apple guidelines suggesting not to do this?
As I see, they are suggesting to put SplitVC as RootVC. But many applications have already done what we are doing now.
Answers here might help Apple recommends UISplitViewController should always be the rootviewcontroller
I had nearly same scenario of creating a UISplitViewController inside a view controller. So I created my own custom SplitViewController
Here is the note from apple
You cannot push a split view controller onto a navigation stack. Although it is possible to install a split view controller as a child in some other container view controllers, doing is not recommended in most cases. Split view controllers are normally installed at the root of your app’s window.
Apple HIG recommends to have tab bar as the root or split view controller as root. But I still achieved this by putting in a container for one of the tab bar's child view controller. And as a result, you can load split view controller into the container view of any view controller, irrespective of whether its tab bar or a normal view controller.

Use of differenct view controllers

i'm curious about what's the best way to plan the controllers for my app.
i want my main screen to have 3 button.
1) should open a nav controller with details view
2) should open a controller with other buttons that lead to others controllers
3) should open a tab bar with 2 pages ( or eventually use a switch to change page instead of the tab bar)
this is the schema of what i want
http://i59.tinypic.com/2rrvrd4.png
Is it a correct schema or i should use my controllers differently? will apple reject an apple with such schema?
thanks
As #Fogmeister pointed out in the comments, going for a UITabBarController as the main interface for your app actually seems to be a more appropriate solution here.
However, you can go with the interface that you described, but then you should keep in mind that with your current setup, you are not only using UINavigationController in the first case, but your whole navigation system is still built upon UINavigationController in the following way:
Your app has one instance of UINavigationController.
Your initial UIViewController (the one with the three buttons), is the rootViewController of your UINavigationController.
You can navigate to the other view controllers using [self.navigationController pushViewController:newViewController] (or performSegue if you prefer using Storyboards).
In the case of your third view controller, you are pushing a UITabBarController onto the navigation controller's view controller stack, this UITabBarController needs to be initialized with the two view controllers that it is going to display before it gets pushed onto the stack.

IPad Split View Implement in Another View

I am creating a iPad App and it has several views to load data,but for one view i need to add split view. I dont need split views in other views. They are just detail pages. I search Through the net and found lots of tutorials based on iPad split view. But the problem is they all are creating a project as Split view project or they create a window base app and add slipt view to the delegate. I dont need to do that, I need to implement this split view only for one view. Is There any way to overcome this problem?
You can add the split view inside a Navigation Controller.
Even if the Split View is a container view controller and Apple recommends in the documentation that all containers should not be embedded in other containers, adding a split view inside a navigation controller works correctly and I never noticed any side effect in doing it.
Basically what you should do is:
- in the app delegate create a UINavigationController and use it as root view of your application window
- hide the navigation controller navigation bar if you don't want to see it (showing a split view with a main navbar on top is not nice looking...)
- then add your view controllers inside the navigation bar.
Example: imagine you have this application views sequence:
FIRST VIEW (full view = detail page)
SECOND VIEW (split view)
THIRD VIEW (full = detail page)
So you can represent FIRST and THIRD as standard view controllers (full screen), while SECOND will be a split view. Your app will be initialized by creating the main navigation controller, adding FIRST on it as top controller and using the main navigation controller as window's root view.
Than use the navigation controller push, pop methods to switch between these views or change the navigation controller "viewControllers" array directly if you don't want the recommended push/pop methods.
If you need to add special behavior to the navigation controller based on the type of view on top, just register your app delegate as navigation controller delegate (or a "main controller" object dedicated to this if you don't want to complicate your app delegate).
I am not 100% sure, but it seems to me that you can't use a SplitView just somewhere in your view hierarchy.
The Apple intended way is to use the SplitViewController as the top level controller. The left side of it can include a drill down mechanism with a navigation controller so you are ably to drill down hierarchies and the right side will present details for the item you select on the left side.
If you need a view with some kind of split mechanism in it, you probably have to code it yourself. Or even better: find some other mechanism you can use in your UI.
How are you switching your view hierarchies now? Maybe you could integrate your existing UI into a SplitViewController?

Can a UISplitViewController be the root controller in a UINavigationController?

Interface builder does not allow you to add a UISplitViewController as the root controller of a UINavigationController.
I've also tried programmatically creating the UINavigationController and setting its root view controller to be the UISplitViewController.
The result is an empty window with just the nav bar.
I've also tried a split view controller replacement, MGSplitViewController. It mostly works, except that within the split view controller, the master view is another UINavigationController. Its nav bar shows up too thick. Changing orientation and back clears it up.
I've been trying all sorts of different approaches to having a view that looks like a split view and other views that I switch between. I've tried within a tab view controller, writing my own controller to manage subviews of the window and having the split view as a managed view, and now the navigation controller. All attempts have had some issues. The most consistent issue is regarding the orientation of the view. My app is running in landscape mode and typically the child views think its still portrait.
Any ideas appreciated.
No.
The bottom line: a UISplitViewController must be the root view of an app (or perhaps more specifically, a window). It can not live inside a UINavigationController or anything else.
This is the case with the current SDK, and there's no guarantee that will change in future SDKs.
It seems strange to add a split view to a navigation stack. The master pane of a split view controller is generally a navigation controller, so (without knowing more about your design), I'd probably use that to control your navigation hierarchy.

Resources