0

I'm trying to add a split view inside of a tab bar, and since the split view isn't the root, it doesn't properly get the rotation notifications, so the delegate's methods are never called to add the button to the toolbar in the detail view.

I've rigged it up so I can generate the popover when rotated, but when this method is called, the view dissappears from the landscape mode, and if you activate it and then rotate back into landscape, it's a black empty box where the master view used to be. How do I get rid of this occuring?

-(void) displayPopover:(id)sender
{
    //Toggle the popover: if it's showing, hide it
    if (popoverController != nil && [popoverController isPopoverVisible]) 
    {
        [popoverController dismissPopoverAnimated:NO];
    }
    else
    {
        //Create a Popover displaying the master view
        if (popoverController == nil)
        {
            popoverController=[[UIPopoverController alloc] initWithContentViewController:self->rootController];
            popoverController.popoverContentSize=CGSizeMake(300, 500);
    }
    [popoverController presentPopoverFromBarButtonItem:[detailController.toolbar.items objectAtIndex:0] permittedArrowDirections:UIPopoverArrowDirectionAny animated:NO];
}
r36363
  • 589
  • 4
  • 15
  • Time left, but let me advise my own [Custom UISplitViewController for iPad](http://iphone-dev-tips.alterplay.com/2011/05/custom-uisplitviewcontroller-for-ipad.html). It does exactly what you want. You may use it as sample how to catch and send rotation events to sub–controllers. – slatvick May 02 '11 at 08:12

3 Answers3

1

I would recommend either finding a way to get your SplitViewController to be root, or creating a custom subclass of the UISplitViewController that allows for non-root placement. I really like what Matt Gemmell did here: http://mattgemmell.com/2010/07/31/mgsplitviewcontroller-for-ipad Using a custom subclass like Matt's will allow you to benefit from all the same delegate methods that a SplitView as root would allow. I used it in a project where I wanted my SplitView to appear as a modal - almost impossible with a traditional UISplitViewController.

weston
  • 79
  • 3
1

You will need to remove all the objects from window using:

 [appdelegate window ] subviews] objectAtIndex:0] removeFromSuperview]; 

Then add your splitview to the window, you can get the view callbacks.

Ahmad Kayyali
  • 8,233
  • 13
  • 49
  • 83
Arun
  • 56
  • 4
0

so your split view has rotation enabled (shouldAutorotateToInterfaceOrientation:) now you have to make sure that the tab controller has also rotation enabled (should be the appDelegate, am I right?) AND you have to make sure that every other view that is in your TabBar has also rotation enabled!

so if your TabBar contains 2 tabs you have to set the rotation in 3 classes.

  • Everything rotates fine, but when the rotation occurs, the split view delegate's method aren't called, because the split view isn't the root controller. – r36363 Dec 22 '10 at 18:40