views:

155

answers:

1

Hi,

I am trying to use a UISplitViewController for only one tab in my application (the others are using a Navigation Controller and different ViewControllers).

I have added the SplitViewController in the MainWindow.xib (the only way I could get it to work) but I don't add it to the window when didFinishLaunchingWithOptions is called as it's usually the case, so the SplitViewController stays hidden.

When I click on the tab I call some code in the delegate window to hide the navigation controller and put the SplitViewController in place with:

[window addSubview:splitViewController.view];

If the iPad is in Landscape mode, the SplitViewController still thinks it's in Portrait mode for some reason and the frame for the Root and Detail View Controller are wrong. If I start rotating the iPad then everything works fine. It's just the initial call that is wrong.

It looks like the SplitViewController is not notified of the initial landscape rotation because it's hidden.

During the first call the frame rect is 320 x 980 for the Root Controller, if the iPad is rotated to Portrait and then back to landscape mode the frame rect becomes 320 x 724.

The problem with the wrong size is that it doesn't display the last items in the TableView in the Root Controller.

I have tried to change the frame size in ViewDidLoad and ViewWillAppear of the Root Controller but it didn't change anything.

Any help would be much appreciated.

A: 

Maybe this can help you a bit.

I have an iPad app with a tab bar with multiple tabs/pages. One of the pages uses a split view controller with the left view also containing a navigation controller. The rotation aspects seem to be working fine. Here is how I set it up:

AppDelegate

MyLeftViewController *viewController = [[MyLeftViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
[viewController release];

MyRightViewController *rightView = [[MyRightViewController alloc] init];

UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
splitViewController.viewControllers = [NSArray arrayWithObjects:navController, rightView, nil];

[rightView release];   
[navController release];

splitViewController.delegate = rightView;
[viewControllersArray addObject:splitViewController];    
[splitViewController release];

...add other view controllers to viewControllersArray...

tabBarController.viewControllers = viewControllersArray;
[viewControllersArray release];
[window addSubview:tabBarController.view];    
Jay Haase