0

I have the following TabBarController with the uiTabBarItems

[Item1, Item2, Item3, Item4]

This struct works fine (Every ViewController is displayed correctly), my problem is:

When I change to another ViewController from Item1, Item2 ... the TabBarItems bottom are hidden/lose

[, , , ]

I'm using the following code to change of viewController from Item1 ViewController

NewViewController *controller = [[NewViewController alloc]init];
[self.tabBarController setViewControllers:[[NSArray alloc] initWithObjects:controller, nil]];

is correct change of viewcontroller with the code showed previously?

EDIT.-

Basically I want to navigate on ViewControllers of Item1 (UITabBar) without lost the UITabBarItems

4

2 に答える 2

0

アクティブなタブを設定する場合は、setViewControllers:すべてのタブが置き換えられるため、使用しないでください。setSelectedIndex:代わりにonを使用する必要がありますUITabBarController

于 2013-03-04T00:19:20.027 に答える
0

これを試して。

このメソッドを呼び出し、提示する場所UITabBar

.h では、

@property (strong, nonatomic) UINavigationController *navigation;
@property(nonatomic, strong) UITabBarController *tabbarcontroller;

.m で、

-(void)loadtabview
{

    self.tabbarcontroller = [[UITabBarController alloc] init];
    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];
    self.firstViewController = [[FirstViewController alloc]initWithNibName:@"firstViewController" bundle:nil];
    navigation = [[UINavigationController alloc] initWithRootViewController:self.firstViewController];
    self.viewController.navigationItem.title=@"First";
    [localControllersArray addObject:navigation];


    self.secondViewController = [[secondViewController alloc] initWithNibName:@"secondViewController" bundle:nil];
    navigation = [[UINavigationController alloc] initWithRootViewController:secondViewController];
    self.secondViewController.navigationItem.title=@"second";
    [localControllersArray addObject:navigation];


    self.ThirdViewController = [[Third ViewController alloc]initWithNibName:@"Third ViewController" bundle:nil];
    navigation = [[UINavigationController alloc] initWithRootViewController:ThirdViewController];
    self.secondViewController.navigationItem.title=@"Third";
    [localControllersArray addObject:navigation];

    tabbarcontroller.viewControllers = localControllersArray;
    self.tabbarcontroller.delegate = self;
    [self.tabbarcontroller setSelectedIndex:0];
    [self.window addSubview:tabbarcontroller.view];

}
于 2013-03-04T06:36:12.470 に答える