Posted By

alfredbaudisch on 09/26/10


Tagged

root iPad UIToolbar uisplitviewcontroller uinavigationcontroller


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
bobbym245
rvachere


Toolbar above UISplitViewController and UISplitViewController as child of UINavigationController


 / Published in: Objective C
 

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.

  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
Posted By: bdenhamtopazticom on November 25, 2010

I've tried lots of different things to get this to work, but with no luck using latest 4.2 iOS. Has anyone been successful?

Posted By: alfredbaudisch on February 17, 2011

Hmm I actually have 2 applications published using exactly this. What are you getting?

You need to login to post a comment.