0

我想要一个应该在导航控制器内的标签栏控制器。我需要将它添加为我的母版页的子视图。如果没有 ARC,此代码可以正常工作。但是在ARC时会出现黑屏。请帮帮我。

UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate = self;

RestaurantListingClass *restList = [[RestaurantListingClass alloc]initWithNibName:@"RestaurantListingClass" bundle:Nil];

UITabBarItem *placeTab = [[UITabBarItem alloc] initWithTitle:@"Places" image:nil tag:1];
    restList.tabBarItem = placeTab;

ReOrderVC *reorder=[[ReOrderVC alloc]initWithNibName:@"ReOrderVC" bundle:Nil];

UITabBarItem *reorderTab = [[UITabBarItem alloc] initWithTitle:@"Re-order" image:nil tag:1];
reorder.tabBarItem=reorderTab;

tabBarController.viewControllers=[NSArray arrayWithObjects:restList,reorder, nil];

UINavigationController *navcontroller =[[UINavigationController alloc]initWithRootViewController:tabBarController];

DesignElementsClass *DEClass = [[DesignElementsClass alloc] init];
[DEClass setImageForsubNAvBar:navcontroller.navigationBar];
[DEClass setImageForsubTabBar:tabBarController.tabBar];
navcontroller.view.frame = view.bounds;

[self addChildViewController:navcontroller];
[self.view addSubview:navcontroller.view];
4

1 回答 1

1
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
UITabBarController *tabBarController = [[UITabBarController alloc] init];

ViewOne *firstView = [storyBoard instantiateViewControllerWithIdentifier:@"ViewControllerOne"];
ViewTwo *secondView = [storyBoard instantiateViewControllerWithIdentifier:@"ViewControllerTwo"];

UITabBarItem *placeTab = [[UITabBarItem alloc] initWithTitle:@"Places" image:nil tag:1];
firstView.tabBarItem = placeTab;

UITabBarItem *reorderTab = [[UITabBarItem alloc] initWithTitle:@"Re-order" image:nil tag:1];
secondView.tabBarItem=reorderTab;

tabBarController.viewControllers=[NSArray arrayWithObjects:firstView,secondView, nil];

UINavigationController *navcontroller =[[UINavigationController alloc]initWithRootViewController:tabBarController];

[self addChildViewController:navcontroller];
[self.view addSubview:navcontroller.view];
于 2014-02-24T08:46:24.917 回答