I was recently displaying a list of items to a user via a tableview in a popover when a button was tapped. The table was displayed sections and headers.
I’m experimenting now with different ways to display the information and I want to try display the data in a UISplitViewController. The left view is a tableviewcontroller with headings. The right view is also a tableviewcontroller with sub headings.
I still want the data to be provided in a popover manner but when I’ve tried this the popover appears with nothing in it. I’ve put breakpoints in the viewDidLoad methods of my left and right view for the SplitView. The breaks are being hit but nothing is displaying in my popover.
How can I display a UISplitView IN a PopoverController.
My Root View
- (IBAction)showPopover:(id)sender {
self.SVC = [[SplitViewContainerViewController alloc] init];
self.pickerPopover = [[[UIPopoverController alloc] initWithContentViewController:SVC] autorelease];
CGRect frame= CGRectMake(0,0, 0, 0);
[self.pickerPopover presentPopoverFromRect:frame inView:self.view permittedArrowDirections:0 animated:NO];
LoadView Of SplitViewContainerViewController
- (void)loadView
{
UIView *view=[[[UIView alloc]initWithFrame:CGRectMake(0, 0, 750, 880)]retain];
self.view=view;
self.splitViewController = [[UISplitViewController alloc] init];
self.leftViewController=[[[LeftViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
self.rightViewController=[[[RightViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
self.splitViewController.viewControllers= [NSArray arrayWithObjects:self.leftViewController, self.rightViewController, nil];
[self.view addSubview:self.splitViewController.view];
self.contentSizeForViewInPopover = CGSizeMake(750,880);
[super loadView];
}
UISplitViewControllers do not work unless they are the root view controller of the window. In order to do something like this you are going to need to create a custom split view controller and use that instead of UISplitViewController.
From Apple’s documentation:
You may want to start by looking at MGSplitViewController, however, be aware that there are some limitations in iOS 4 and below including the inability to correctly forward rotation and view appearance and disappearance events to the child view controllers.