0

I am new to SplitViewController and I am running into the following issue. Here is the setup:

In IB, I only have a VC linked to the SVC as the detail VC (This compares to the standard Master Detail project template which has a Nav Controller as the starting point for the detail Hierarchy). I am doing this to try to maximize image space in the detail VC.

I then add a UIToolbar (called imageTable) to the detail VC which I connect with an IBoutlet to the detail VC class.

I am using the detail VC as the SVC delegate.

I then adopt the follow SVC delegate 3 methods in the detail VC:

#pragma mark - SplitViewController Delegates
-(BOOL) splitViewController:(UISplitViewController *)svc
   shouldHideViewController:(UIViewController *)vc
             inOrientation:(UIInterfaceOrientation)orientation
{
  return UIInterfaceOrientationIsPortrait(orientation); 
}



-(void) splitViewController:(UISplitViewController *)svc
     willHideViewController:(UIViewController *)aViewController
         withBarButtonItem:(UIBarButtonItem *)barButtonItem
      forPopoverController:(UIPopoverController *)pc
{    
  barButtonItem.title=@"ImageList";
  NSMutableArray *toolbarItems=[self.imageTable.items mutableCopy];
  [toolbarItems insertObject:barButtonItem atIndex:0];
  self.imageTable.items=toolbarItems;
}



-(void) splitViewController:(UISplitViewController *)svc
     willShowViewController:(UIViewController *)aViewController
  invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
  NSMutableArray *toolbarItems=[self.imageTable.items mutableCopy];
  [toolbarItems removeObjectAtIndex:0];
  self.imageTable.items=toolbarItems;
}

Because I am not using Nav Controller as the starting point in the VC, I am running into the following:

  • UIToolBar automatically disappears when I turn back to landscape. Is it inherent in the SVC class that since the UIBarbuttonItem representing the VC to reappear is no longer needed in landscape, so is the UIToolbar I created (emphasizing 'I')...

  • Is there any way to add or enable a title to the UIToolbar or is the only way using a label.

Thanks

Khaled Barazi
  • 8,681
  • 6
  • 42
  • 62

2 Answers2

0

Check out the MultipleDetailViews sample code my apple. They create the UIToolBar in code (in their first view controller),

@property (nonatomic, retain) IBOutlet UIToolbar *toolBar;

And then declare UINavigationBars for their other views

@property (nonatomic, retain) IBOutlet UINavigationBar *navigationBar;

I used this sample code as a starting point for my project, and everything is working smoothly.

Also I'm not sure how new you are to Objective-C, but you may want to check out this tutorial on using the MultipleDetailViews sample code.

Community
  • 1
  • 1
BloonsTowerDefence
  • 1,184
  • 2
  • 18
  • 43
0

I have been pushing a bit forward in CS193P class and I gather the simple answer is:

If you are ever in need of a UIToolbar (to add Buttons or a title), just embed the Table View Controller or any view Controller you are working on, in a Navigation controller - this way you get a free UIToolbar (with easy access to title, etc..)

Do that even if you have no need to push/pop or segue.

KMB

Khaled Barazi
  • 8,681
  • 6
  • 42
  • 62