Should UISplitViewController be the root controller of an iPad application?

According to Apple's documentation on the UISplitViewController (in the new iPad 3.2 SDK), it seems they intend to use it only as the root controller of the application. In other words ... it looks like you cannot click the UISplitViewController on the UINavigationController, because obviously the UINavigationController should have a shared view.

Can anyone confirm if this is a true limitation of the UISplitViewController? I was hoping to use the split view in my application at several levels in my UINavigationController hierarchy, but it looks like I can't do it unless there is a way.

Thank!

+3
source share
5 answers

My application crashes every time I try to submit a UISplitViewController.

+5
source

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 .

. .

+2

Apple HIG , . , , , , , .

+1

, , : . .

0

Source: https://habr.com/ru/post/1733932/


All Articles