iPad Split View Call/Load from another view

后端 未结 2 1428
感情败类
感情败类 2021-01-14 23:24

Please help me with the issue mentioned below.

My issue is, whether there is way to call the split view from another view, say after I tap on a button..?

For

2条回答
  •  情深已故
    2021-01-15 00:25

    Check the foll code. This should easily help you to solve your issue.

       //Intialise the 2 views root and detail
        RootViewController * rootVC = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
    
        //To show the nav bar for root, add it into a UINavigationController
        UINavigationController * rootVCNav = [[UINavigationController alloc] initWithRootViewController:rootVC];
    
    
        DetailViewController * detailVC = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
    
        //initialise split view
        splitVC = [[UISplitViewController alloc] init];
        splitVC.viewControllers = [NSArray arrayWithObjects:rootVCNav,detailVC, nil];
    
        //Tell the split view that its delegate is the detail view.
        splitVC.delegate = detailVC;
        //tell root that the changes need to be shown on detail view.
        rootVC.detailViewController = detailVC;
    
    
        [rootVC release];
        [detailVC release];
        [rootVCNav release];
    
        //Here, we get the app delegate object of the project
        ProjectAppDelegate * appDel = (ProjectAppDelegate*)[[UIApplication sharedApplication] delegate];
    
        //get window object of the delegate
        UIWindow * window1 = [appDel window];
        //get the navigation controler of the window of app delegate.
        mainNav = [appDel rVC];
    
        //remove the current view from the window.
        [mainNav.view removeFromSuperview];
    
        //add the split view to the window
        [window1 addSubview:locSplitVC.view];
    

    Hope this helps you..

    Regards, Melvin

提交回复
热议问题