Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Uitabbarcontroller UITabBar内部主视图_Uitabbarcontroller_Uisplitviewcontroller - Fatal编程技术网

Uitabbarcontroller UITabBar内部主视图

Uitabbarcontroller UITabBar内部主视图,uitabbarcontroller,uisplitviewcontroller,Uitabbarcontroller,Uisplitviewcontroller,我需要创建一个具有拆分视图的应用程序,但我需要在拆分的主控端添加一个选项卡栏,我在这个论坛上读了一些东西,但我就是做不好。 我知道当你有一个分割视图时,你实际上要处理两个视图控制器-主视图和细节视图-所以,据我所知,如果我在主机端需要一个选项卡栏,我必须从appDelegate调用主机,在这个主机内,我可以将它设置为选项卡栏控制器,但要么我完全误解了,要么我只是实现了错误 下面是我在appDelegate中所做的,正如您所看到的,我正在加载的是另一个VC,而不是模板附带的主VC,我的第一个问题是

我需要创建一个具有拆分视图的应用程序,但我需要在拆分的主控端添加一个选项卡栏,我在这个论坛上读了一些东西,但我就是做不好。 我知道当你有一个分割视图时,你实际上要处理两个视图控制器-主视图和细节视图-所以,据我所知,如果我在主机端需要一个选项卡栏,我必须从appDelegate调用主机,在这个主机内,我可以将它设置为选项卡栏控制器,但要么我完全误解了,要么我只是实现了错误

下面是我在appDelegate中所做的,正如您所看到的,我正在加载的是另一个VC,而不是模板附带的主VC,我的第一个问题是,我是否必须加载一个VC或只是一个带有tab bar协议的NSObject

WTDInitialViewController *initialViewController = [[WTDInitialViewController alloc] initWithNibName:@"WTDInitialViewController" bundle:nil];
    UINavigationController *initialNavigationController = [[UINavigationController alloc] initWithRootViewController:initialViewController];

    WTDDetailViewController *detailViewController = [[WTDDetailViewController alloc] initWithNibName:@"WTDDetailViewController_iPad" bundle:nil];
    UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:detailViewController];

    self.splitViewController = [[UISplitViewController alloc] init];
    self.splitViewController.delegate = detailViewController;
    self.splitViewController.viewControllers = [NSArray arrayWithObjects:initialNavigationController, detailNavigationController, nil];

    self.window.rootViewController = self.splitViewController;
现在,这就是我在所谓的VC中所做的

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
    NSMutableArray *vcArray = [[NSMutableArray alloc] initWithCapacity:1];
    _tabBarController = [[UITabBarController alloc] init];
    WTDMasterViewController *masterViewController = [[WTDMasterViewController alloc] initWithNibName:@"WTDMasterViewController_iPad" bundle:nil];
    _navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
    _navigationController.navigationBar.barStyle = UIBarStyleBlack;
    [vcArray addObject:_navigationController];

    _tabBarController.viewControllers = vcArray;
    _tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.tabBarController.selectedIndex = 0;
    [_window addSubview:_tabBarController.view];
    [_window makeKeyAndVisible];
}
return self;

这可能是一个愚蠢的问题,但我遇到了一个死胡同,因此,任何帮助都将不胜感激。

首先,我假设您正在为ipad创建SplitView。它的首字母是MasterViewController和DetailViewController。MasterViewController是UITableview base,现在您想实现Tabbar base,然后只需在MasterViewController的视图中调用do this

UIViewController *viewController1 = [[[YourTabView1 alloc] initWithNibName:@"YourTabView1" bundle:nil]autorelease];
//If you want the view support Navigation then do this
UINavigationController *tab1 = [[[UINavigationController alloc] initWithRootViewController:viewController1]autorelease];

UIViewController *viewController2 = [[[YourTabView2 alloc] initWithNibName:@"YourTabView2" bundle:nil]autorelease];
UINavigationController *tab2 = [[[UINavigationController alloc] initWithRootViewController:viewController2]autorelease];

UITabBarController *tabbarController = [[UITabBarController alloc] init];
tabbarController.viewControllers = [NSArray arrayWithObjects:tab1,tab2,nil];

[self presentModalViewController:tabbarController animated:YES];
我认为这应该行得通,但我没有测试代码