Reputation:
In my application. I have to use UISplitViewController
and I want to do add UISplitViewController
To UINavigationController
but I can't do this.
I also know that inheritance of UISplitViewController
is not possible. but it very important for me to add in UINavigationController
.
Thanks in advance :)
Upvotes: 2
Views: 3448
Reputation: 701
Refer this Q&A - Is it possible to implement a Split View Controller within a Navigation Controller in an iOS app?
This violates Apples guidelines (https://developer.apple.com/library/archive/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/SplitViewControllers.html#//apple_ref/doc/uid/TP40011313-CH7)
A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.
Upvotes: 0
Reputation: 19418
You can add MGSplitViewController
in delegate like :- in .m file
self.splitViewController = [[[MGSplitViewController alloc] init] autorelease];
//
MasterPage *aMasterPage = [[[MasterPage alloc] initWithNibName:@"MasterPage" bundle:[NSBundle mainBundle]] autorelease];
aMasterPage.splitViewController = self.splitViewController;
self.splitViewController.delegate = aMasterPage;
UINavigationController *navCntrl = [[[UINavigationController alloc] aMasterPage] autorelease];
[navCntrl.navigationBar setBarStyle:UIBarStyleBlackOpaque];
DetailPage *aDetailPage = [[[DetailPage alloc] initWithNibName:@"DetailPage" bundle:[NSBundle mainBundle]] autorelease];
UINavigationController *navCntrl2 = [[[UINavigationController alloc] initWithRootViewController:aDetailPage] autorelease];
[navCntrl2.navigationBar setBarStyle:UIBarStyleBlackOpaque];
[self.splitViewController setViewControllers:[NSArray arrayWithObjects:navCntrl, navCntrl2, nil]];
[self.window addSubview:self.splitViewController.view];
Upvotes: 1
Reputation: 6152
I've been able to do this using the open source MGSplitViewController.
Upvotes: 1
Reputation: 38249
Note: 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.
refer can-a-uisplitviewcontroller-be-the-root-controller-in-a-uinavigationcontroller link
Upvotes: 6