how can i add splitview to my viewbased app in ipad coding

前端 未结 3 1859
梦如初夏
梦如初夏 2021-01-07 09:20

I am Started my iPad app using View-Based application. in first two views i added table views. Now as the third view i want add splitView to the view, for this purpose i add

3条回答
  •  余生分开走
    2021-01-07 09:50

    When you want to switch to your splitview controller you need to alloc/init it then you need to set your windows root view controller to the splitview controller.

    For example in my app, I have a main home view, and when the user taps a button I switch to a splitview. To swtich to the splitview controller I use the following code.

    Get a reference to your app delegate

    MainAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    

    Alloc and initialise your splitview controller, so for my example I have a section list controller on the left, and a section details controller on the right:

    SectionListViewController *sectionListVC = [[SectionListViewController alloc] init];
    SectionViewController *sectionVC = [[SectionViewController alloc] init];
    
    UISplitViewController *splitVC = [[UISplitViewController alloc] init];
    splitVC.viewControllers = [NSArray arrayWithObjects:sectionListVC, sectionVC, nil];
    
    appDelegate.window.rootViewController = splitVC;
    
    [sectionListVC release];
    [sectionVC release];
    [splitVC release];
    

提交回复
热议问题