Toolbar above UISplitViewController and UISplitViewController as child of UINavigationController


/ Published in: Objective C
Save to your folder(s)

As default UISplitViewController has to be the root controller. In this snippet, you can have one as a child of a UINavigationController and also an UIToolbar above the SplitViewController! The same as Epicurious app for iPad.


Copy this code and paste it in your HTML
  1. // Define rootController as a UINavigationController, then...:
  2.  
  3. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  4. {
  5. // Sets up toolbar above splitview
  6. rootController.navigationBar.hidden = YES;
  7.  
  8. CGFloat width = rootController.view.frame.size.width;
  9.  
  10. NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"toolbar" owner:self options:nil];
  11. toolbar = (Toolbar *)[nib objectAtIndex:0];
  12. toolbar.frame = CGRectMake(0,20,width,TOOLBAR_HEIGHT);
  13. [rootController.view addSubview:toolbar];
  14.  
  15. NSMutableArray *array = [NSMutableArray array];
  16.  
  17. UISplitViewController *splitViewConntroller = [[UISplitViewController alloc] init];
  18.  
  19. leftViewController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
  20. [array addObject:leftViewController];
  21.  
  22. rightViewController = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];
  23. [array addObject:rightViewController];
  24.  
  25. [splitViewConntroller setViewControllers:array];
  26.  
  27. [rootController setViewControllers:[NSArray arrayWithObject:splitViewConntroller]];
  28. [splitViewConntroller release];
  29.  
  30. [window addSubview:rootController.view];
  31. [window makeKeyAndVisible];
  32.  
  33. return YES;
  34. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.