How to create a UISplitView manually?

I have an application that is going to switch to a UISplitView (inside another view in general):

- (void) switchToMyDayView {
    NSLog(@"Show My Day Screen");

    if (self.myDayController.view.superview == nil) {
        if (self.myDayController == nil) {
            MyDayController *myController = [[MyDayController alloc] initWithNibName:@"MyDay" bundle:nil];
            self.myDayController = myController;
            [myController release];
        }

        [homeScreenController.view removeFromSuperview];
        [self.view insertSubview:self.myDayController.view atIndex:0];
    }
}

What is done on the main navigation screen

Now MyDayController has an XIB called MyDay.xib, which has the following elements:

File Owner: MyDayController

First responder: UIResponder

Controller split view

 ---->Navigation Controller

         ---->Navigation Bar

         ----> Table View Controller

                 ----> Navigation Item

 ---->View Controller

So I need a few more components, do I need a UITableViewController and a UISplitViewControllerDelegate right?

I was going to just implement these protocols in MyDayController, is that such a standard?

So, after the code above, I get an error:

- [UIViewController _loadViewFromNibNamed: bundle:] loaded "MyDay", but the exit viewpoint was not set.

, UISplitViewController? , UISplitViewController view, / IB, ?

+3
4

UISplitViewController. "MyDayController"? UISplitViewController , .

, . , :

- (void) switchToMyDayView {
    NSLog(@"Show My Day Screen");

    if (self.myDayController == nil) {
        YourMasterViewController *masterViewController = [[YourMasterViewController alloc] initWithNibName:@"MasterView" bundle:nil];
        YourDetailViewController *detailViewController = [[YourDetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
        UISplitViewController *myController = [[UISplitViewController alloc] init;
        myController.viewControllers = [NSArray arrayWithObjects:masterViewController, detailViewController, nil];
        [masterViewController release];
        [detailViewController release];

        self.myDayController = myController;
        [myController release];         
    }

    [homeScreenController.view removeFromSuperview];
    [self.view insertSubview:self.myDayController.view atIndex:0];
}

self.myDayController.view.superview == nil, self.myDayController == nil

+5

, . , , . . .

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    LeftViewController *leftViewController = [[LeftViewController alloc] init];// initWithNibName:@"LeftViewController" bundle:nil];
    RightViewController *rightViewController = [[RightViewController alloc] initWithNibName:@"RightViewController" bundle:nil];
    UISplitViewController *myController = [[UISplitViewController alloc] init];
    myController.viewControllers = [NSArray arrayWithObjects:leftViewController, rightViewController, nil];

    self.window.rootViewController = myController;

    [self.window makeKeyAndVisible];
    return YES;
}

, .

+1

.

, .

, Madhup

0

, ,

self.rootViewController=[[RootViewController alloc]init];
    self.detailViewController=[[FirstDetailViewController alloc]init];

    UINavigationController *rootNav=[[UINavigationController alloc]initWithRootViewController:rootViewController];
    UINavigationController *detailNav=[[UINavigationController alloc]initWithRootViewController:detailViewController];

    self.splitViewController.viewControllers=[NSArray arrayWithObjects:rootNav,detailNav,nil];
    self.splitViewController.delegate=self.detailViewController;
0

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


All Articles