0

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?

Sameera Chathuranga
  • 3,486
  • 1
  • 25
  • 46

2 Answers2

0

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).

viggio24
  • 12,121
  • 5
  • 39
  • 34
0

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?

Florian
  • 491
  • 4
  • 7