Multi-level navigation controller on the left side of the UISplitView with a slight rotation

I am trying to make something similar (but not quite) the email application found on the iPad .

In particular, I would like to create a tab-based application , but each tab would introduce a different UISplitView to the user .

Each UISplitView contains a "Master and Part" view (obviously).

In each UISplitView, I would like the Wizard to be a multi-level navigation controller, where new UIViewControllers are pushed onto the stack or popped out of it. This type of navigation in UISplitView is an application similar to a native email application.

As far as I know, the only place where a decent "splitviewcontroller inside the uitabbarcontroller" is described is here: UISplitViewController in TabBar (UITabBarController)? and I tried to follow the accepted answer.

The decision made works for me (i.e. I get a tab controller that allows me to switch between different UISplitViews).

The problem is that I do not know how to make the left side of the UISplitView a multi-level navigation controller.

Here is the code that I used in my application delegate to create the initial “split view” inside the “tab bar controller” (this is pretty much as suggested in the above link).

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    NSMutableArray *tabArray = [NSMutableArray array];

    NSMutableArray *array = [NSMutableArray array];
    UISplitViewController *splitViewController = [[UISplitViewController alloc] init];
    MainViewController *viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
    [array addObject:viewCont];
    [viewCont release];
    viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
    [array addObject:viewCont];
    [viewCont release];
    [splitViewController setViewControllers:array];
    [tabArray addObject:splitViewController];
    [splitViewController release];



    array = [NSMutableArray array];
    splitViewController = [[UISplitViewController alloc] init];
    viewCont = [[Master2 alloc] initWithNibName:@"Master2" bundle:nil];
    [array addObject:viewCont];
    [viewCont release];
    viewCont = [[Slave2 alloc] initWithNibName:@"Slave2" bundle:nil];
    [array addObject:viewCont];
    [viewCont release];
    [splitViewController setViewControllers:array];
    [tabArray addObject:splitViewController];
    [splitViewController release];

        // Add the tab bar controller current view as a subview of the window
    [tabBarController setViewControllers:tabArray];

    [window addSubview:tabBarController.view];
    [window makeKeyAndVisible];

    return YES;
}

MainViewController - UIViewController, :

- (IBAction)push_me:(id)sender {
    M2 *m2 = [[[M2 alloc] initWithNibName:@"M2" bundle:nil] autorelease];
    [self.navigationController pushViewController:m2 animated:YES];
}

( ) UIButton, MainViewController.xib. , (push_me) UIViewController ( m2) m2 UIButton . , ( , ).

, ?

!

+3
2

, MainViewController UINavigationController?

, push/pop-, mainViewController ( ), (, TableViewControllers). splitView ( IB ).

UISplitViewController: http://mobiforge.com/developing/story/developing-split-view-based-apps-ipad

0

() :

- separateSecondaryViewControllerForSplitViewController:

overriden , , , :

- collapseSecondaryViewController:forSplitViewController:

Swift:

import UIKit

class MasterNavigationController: UINavigationController {

    override func separateSecondaryViewControllerForSplitViewController(splitViewController: UISplitViewController) -> UIViewController? {

        // Separate a view controller from master navigation controller
        if let secondaryViewController = super.separateSecondaryViewControllerForSplitViewController(splitViewController) {

            if /* Check if secondaryViewController is your Detail View Controller (you can check for its class or restorationIdentifier for example) */ {

                return secondaryViewController

            } else {

                // Remerges the separated view controller back to the master navigation controller
                super.collapseSecondaryViewController(secondaryViewController, forSplitViewController: splitViewController)
            }
        }
        return nil
    }
}
0

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


All Articles