我的应用程序委托中有我的 UINavigationController 设置,我用它来推送我的登录页面。登录后,正在调用的视图将显示 UITabBarController 并为每个选项卡提供每个单独的 UINavigationController。我的问题是,当我通过标签栏中的导航控制器推送视图时,它什么也不做。它根本不会推动视图。我不知道下一步该怎么做才能使 pushViewController 正常工作。很感谢任何形式的帮助。谢谢。
这是我的代码:
登录时将调用此函数--来自 rootView 类
- (void) login
{
UIViewController *_mainPageViewController = [[MainPageViewController alloc] initWithNibName:@"MainPageViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:_mainPageViewController animated:YES];
}
MainPageViewController.class--
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
[self setUpTabBar];
}
return self;
}
-(void)setUpTabBar {
MeViewController *_meViewController = [[MeViewController alloc]init];
_meViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"me"
image:[UIImage imageNamed:@"img1.png"] tag:1];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:_meViewController];
TodoViewController *_todoViewController = [[TodoViewController alloc]init];
_meViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"me"
image:[UIImage imageNamed:@"img2.png"] tag:1];
UINavigationController *secondNavController = [[UINavigationController alloc]initWithRootViewController:_meViewController];
mainBarController.viewControllers = [[NSArray alloc] initWithObjects: firstNavController, secondNavController, nil];
mainBarController.delegate = self;
mainBarController.selectedIndex=0;
[firstNavController release];
[_meViewController release];
[secondNavController release];
[_exploreViewController release];
[[[UIApplication sharedApplication]keyWindow]addSubview:mainBarController.view];
}
MeViewController.class——它根本不推送视图
- (IBAction)showMeInfo:(id)sender {
UIViewController *_meInfoViewController = [[MeInfoViewController alloc] initWithNibName:@"MeInfoViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:_meInfoViewController animated:YES];
}