Declare your splitview controller in your delegate header, use something like this in your dofinishlaunching
make sure you add the UISplitViewControllerDelegate to the detailViewController header file and that you also have delegate methods. don't forget to import the corresponding header files
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { splitViewController = [[UISplitViewController alloc] init]; rootViewController *root = [[rootViewController alloc] init]; detailedViewController *detail = [[detailedViewController alloc] init]; UINavigationController *rootNav = [[UINavigationController alloc] initWithRootViewController:root]; UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:detail]; splitViewController.viewControllers = [NSArray arrayWithObjects:rootNav, detailNav, nil]; splitViewController.delegate = detail; [window addSubview:splitViewController.view];
EDIT - as per Scott's recommendations below, don't add a subview to the window, instead
[self.window setRootViewController:(UIViewController*)splitViewController];
I also prefer code for IB; -)
Nik Burns Jun 04 2018-10-06T00: 00Z
source share