我有两个标签栏,以便产生类似于在UITabBarController 中滑动 UITabBarItems 的问题中所示的效果
我试图在最后一个索引处使用标签栏项目而不是箭头来显示另一个标签栏,并隐藏当前的标签栏。我正在以编程方式添加第二个标签栏viewDidLoad
。问题是当最后一个标签栏项目被点击时,我的第二个标签栏没有出现。我所做的是:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.tabControler.view.frame = self.view.frame;
self.tabControler.delegate = self;
self.secondTabBarSelected = NO;
self.secondTabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, 431, 320, 49)];
self.secondTabBar.hidden = YES;
self.secondTabBar.delegate = self;
self.secondTabBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.tabControler.view addSubview:secondTabBar];
[self.view addSubview:tabControler.view];
NSLog(@"children of tabcon: %@",[tabControler.view subviews]); //Here second tab bar added with correct frame
}
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if (!self.secondTabBarSelected) {
NSLog(@"first tab bar");
if([[tabBarController viewControllers] indexOfObject:viewController] == 3)
{
self.firstTabBar.hidden = YES;
self.secondTabBar.hidden = NO;
}
}
}