目前我在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),在标签标题更改谷歌时。 我无法解决这个问题,请帮助我。
先谢谢
答案 0 :(得分:0)
Apple的开发者文档声明如下:
"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];
答案 1 :(得分:0)
您可以将Tabbar推送到Controller By
[self.navigationController pushViewController:tabBar animated:YES];
或强>
[self presentModalViewController:tabBar animated:YES];
希望这能解决你的问题
答案 2 :(得分:0)
在此
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
每个视图的方法Controller输出以下代码..
self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Comment" image:[UIImage imageNamed:@"Icon-AddComment.png"] tag:0];
self.navigationItem.title = @"Comment";
它有效