1

我现在正在努力实现两件事:

1)在导航控制器中有一个标签栏控制器

2)根据选定的选项卡,一些导航按钮会发生变化,我想将一些视图推送到导航控制器中,同时保持在当前选定的选项卡内。

现在,我像这样推动导航控制器:

GenericAddViewController *vc = [[GenericAddViewController alloc]init];
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:vc];
navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:navigationController animated:YES completion: nil];

然后,在 GenericAddViewController.m 我有:

@interface GenericAddViewController ()
@property (strong, nonatomic) UITextField *titleTextField;
@property (nonatomic, strong) UITabBarController *tabBarController;

@end

@implementation GenericAddViewController

-(void)loadView
{
[super loadView];

TabOneController *tabOneController = [[TabOneController alloc]init];
tabOneController.title = @"Steps";

TabTwoController *tabTwoController = [[TabTwoController alloc]init];
tabTwoController.title = @"More Information";   

NSArray *controllers = [NSArray arrayWithObjects:tabOneController, tabTwoController, nil];

self.tabBarController = [[UITabBarController alloc]init];
self.tabBarController.view.frame = CGRectMake(0, 0, 768, 1004);
self.tabBarController.viewControllers = controllers;
self.tabBarController.delegate = self;

}

这行得通。唯一的问题是例如在 TabOneController 中,我不能做任何这些:

UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(isDone:)];
[self.navigationItem setRightBarButtonItem:doneButton animated:NO];

也不 [self.navigationController push...]

不应该那么复杂吧?!

非常感谢!

4

0 回答 0