UISplitViewController in a TabBar ( UITabBarController )?

前端 未结 9 871
长发绾君心
长发绾君心 2020-11-30 19:35

I am in kind of situation that I need to start with a tab based application and in that I need a split view for one or more tabs. But it seems that split view controller obj

9条回答
  •  感情败类
    2020-11-30 20:14

    You can use IB to build tabtab and modify tabs to splitviewcontroller.

    -(void) makeSplitViewController {
    NSMutableArray *controllers = [NSMutableArray arrayWithArray:tabBarController.viewControllers];
    int index = 0;
    
    for (UIViewController *controller in tabBarController.viewControllers) {
        if ([controller.tabBarItem.title isEqualToString:@"Stock"]) {
            stockDetailController = [[StockDetailController alloc] initWithNibName:@"StockDetailController" bundle:nil];
    
            stockMasterController = [[StockMasterController alloc] initWithStyle:UITableViewStylePlain]; 
            stockMasterController.navigationItem.title = date;
            stockMasterController.stockDetailController = stockDetailController;
    
            UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:stockMasterController] autorelease];
    
            splitViewController = [[UISplitViewController alloc] init];
            splitViewController.tabBarItem = controller.tabBarItem;
            splitViewController.viewControllers = [NSArray arrayWithObjects:nav, stockDetailController, nil];
            splitViewController.delegate = stockDetailController;
    
            [controllers replaceObjectAtIndex:index withObject:splitViewController];
        }
    
        index++;
    }
    
    tabBarController.viewControllers = controllers;
    

    }

提交回复
热议问题