Pergunta

Currently I have 5 tabs. The third tab is supposed to show a view which takes space only half of the screen, and the rest requires entire screen. I wonder how I can display tab3's view on top of the rest of tabs'. Suppose current selected tab is 2 and the user pressed tab3, it shows tab3's view on top of tab2's view. Is it possible to do that? Or I have to create my own View and fake the tab controller.

Foi útil?

Solução

Problem Solved; Not very elegant but it works. I fake Tab 3 with a view controller that has no view and make tabItem 3 as a trigger that presents a view controller. something like this:

duplicatedTab3 = [[Tab3 alloc] init]
[tabbarController setViewControllers:[NSArray arrayWithObjects:tab1,tab2,tab3,tab4,tab5,nil]];

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
    BOOL flag = NO;
    NSUInteger tabIndex = [tabBarController.viewControllers indexOfObject:viewController];
    if (viewController == [tabBarController.viewControllers objectAtIndex:tabIndex] &&
       tabIndex != tabBarController.selectedIndex) {
       if ([viewController isMemberOfClass:tab3]) {
           if (![duplicatedTab3 isShowing])
               [duplicatedTab3 show];
           else 
               [duplicatedTab3 hide];
       }
       else {
           flag = YES;
       }
    }
    return flag;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top