0

目前我正在使用 iPhone 应用程序,我有四个屏幕,如登录、A、B 和 c 等。用户在登录屏幕中输入用户名和密码字段,然后按登录按钮

-(void)LoginButtonMethod
{

    A *a = [[A alloc]init];
    B *b = [[B alloc]init];
    C *c = [[C alloc]init];

    UINavigationController *navi1 = [[UINavigationController alloc] initWithRootViewController:a];
    UINavigationController *navi2 = [[UINavigationController alloc] initWithRootViewController:b];
    UINavigationController *navi3 = [[UINavigationController alloc] initWithRootViewController:c];

    UITabBarController *TabBar = [[UITabBarController alloc] init];
    TabBar.delegate = self;
    TabBar.viewControllers = [NSArray arrayWithObjects:navi1, navi2, navi3, nil]; 
    navi1.tabBarItem.title=@"A";
    navi2.tabBarItem.title=@"B";
    navi3.tabBarItem.title=@"C";

    [self.navigationController pushViewController:TabBar animated:YES]; 
}

然后我为每个类设置导航栏标题,例如 A 作为 facebook,b 作为 yahoo,c 作为 google。

最后我运行应用程序,标签栏标题显示在 A,B,C 然后我选择第三个标签栏项目(C),此时标签栏标题更改谷歌。我无法解决这个问题,请帮助我。

提前致谢

4

3 回答 3

0

您可以通过将 Tabbar 推送到控制器

任何一个

[self.navigationController pushViewController:tabBar animated:YES];

或者

[self presentModalViewController:tabBar animated:YES];

希望这能解决您的问题

于 2012-10-05T11:18:35.347 回答
0

苹果在其开发者文档中声明如下:

    "You never want to push a tab bar controller onto the navigation stack of a navigation controller. Doing so creates an unusual situation whereby the tab bar appears only while a specific view controller is at the top of the navigation stack. Tab bars are designed to be persistent, and so this transient approach can be confusing to users."

尝试展示它

[self presentModalViewController:tabBar animated:YES];
于 2012-10-05T11:12:42.530 回答
0

在这

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

每个视图控制器的方法放下面的代码..

self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Comment" image:[UIImage imageNamed:@"Icon-AddComment.png"] tag:0];

self.navigationItem.title = @"Comment";

有用

于 2012-10-05T13:01:20.717 回答