我正在努力实现两件事:
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 ...]
不应该那么复杂吗?!
非常感谢!