This is an old post, but I found it helpful to help me think differently, and that is how I solved the problem.
I created the program code splitViewController. Then I marked it with a number and simply added it as a subitem to the current view.
FirstViewController* firstView = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
SecondViewController* secondView = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
UISplitViewController* splitVC = [[UISplitViewController alloc] init];
[splitVC setDelegate:secondView];
splitVC.viewControllers = [NSArray arrayWithObjects:firstView, secondView, nil];
splitVC.view.tag = 99;
[self.view addSubview:splitVC.view];
After that, it is displayed splitView, but in order to get rid of it, I have to remove it from the view, so I created a notification between viewcontrollers. In the main controller, I added an observer. (note: the main view controller is not, splitViewControlleror one of its views, it is a view controller that loads splitViewController)
NSNotificationCenter *splitViewObserver = [NSNotificationCenter defaultCenter];
[splitViewObserver addObserver:self selector:@selector(removeSplitView) name:@"removeSplitView" object:nil];
"removeSplitView" for UIView 99 .
NSArray *subviews = [self.view subviews];
for (int i = 0; i < [subviews count]; i++) {
if ([[subviews objectAtIndex:i] isKindOfClass:[UIView class]]) {
UIView *tempView = [subviews objectAtIndex:i];
if (tempView.tag == 99) {
[[subviews objectAtIndex:i] removeFromSuperview];
}
}
}
firstView , done, , ViewController.
-(IBAction) done:(id)sender {
[fileSelectedNotification postNotificationName:@"removeSplitView" object:self];
}
fileSelectedNotification . viewDidLoad. .
fileSelectedNotification = [NSNotificationCenter defaultCenter];
, ,
NSNotiicationCenter *filesSelectedNotification;
.h ViewController.
, "" ( ), splitViewController .
. .