2012-09-17 3 views
0

새로운 기능인 ios입니다. Tabbar 컨트롤러에 문제가있었습니다. 내 프로젝트에서 두 개의 탭 막대 컨트롤러를 사용하고 있습니다. 하나는 점심 시간에로드되고 잘 작동합니다. 다른 행을로드하려고합니다. 어떻게해야합니까? 나는 많은 실험을했지만 아무것도 작동하지 않습니다.내비게이션 컨트롤러를 사용하여 tabbar 컨트롤러 xib를로드하는 방법

+0

(http://mattgemmell.com/2008/12/08/what-have-you-tried/) – akk

+0

귀하의 질문 제목과 설명이 다른 것을 알 것 같다 질문. 당신은 실제로 무엇을하고 싶습니까? 상위 뷰 컨트롤러는 무엇입니까? NavigationController 또는 Tabbarcontroller? – Neo

답변

0
-(void) hidetabbar { 
    [UIView animateWithDuration:0.5 
         animations:^{ 
          for(UIView *view in tabBarController.view.subviews) 
          { 
           if([view isKindOfClass:[UITabBar class]]) 
           { 
            if (hiddenTabBar) { 
             [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)]; 
            } else { 
             [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)]; 
            } 
           } else { 
            if (hiddenTabBar) { 
             [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)]; 
            } else { 
             [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)]; 
            } 
           } 
          } 
         }]; 
    hiddenTabBar = !hiddenTabBar; 
} 


when u r clicking on the table view did select row hide the tabbar in the viewcontroller that u r sending 

-(void)viewDidAppear:(BOOL)animated{ 
    [super viewDidAppear:YES]; 
    [((AppDelegate*)[[UIApplication sharedApplication]delegate]) hidetabbar]; 
} 








-(void)tabBarControllerView 
{ 
    tabBarController = [[UITabBarController alloc] init]; 
    tabBarController.view.backgroundColor = [UIColor blackColor]; 
    tabBarController.delegate = self; 
    //Add some tabs to the controller... 

    //----First tab----// 
    //-----second Tab -----// 

    //------3rd tab--// 

    //-----4th tab bar--------// 

    //-----5th tab bar--------// 

    [self.view addSubview:tabBarController.view]; 



    [navigationController pushViewController:tabBarController animated:YES]; 
    tabBarController.tabBar.tag=100; 

    tabBarController.view.hidden = NO; 
} 


- (void)tabBarController:(UITabBarController *)tabBarControllers didSelectViewController:(UIViewController *)viewController 
{ 
    if (tabBarControllers.selectedIndex == 0) 
    { 
    } 
    else if (tabBarControllers.selectedIndex == 1) 
    { 

    } 
    else if (tabBarControllers.selectedIndex == 2) 
    { 


    } 
    else if (tabBarControllers.selectedIndex == 3) 
    { 
    } 
    else if (tabBarControllers.selectedIndex == 4) 
    { 

    } 
} 

통해 UR이 테이블 선택을했고, 또 다른 탭 표시 줄을 추가하고 해당 뷰 컨트롤러의 주요 탭 표시 줄을 숨기 .. 는 didSelect 이벤트에 다음 코드를 추가는 U에게

+0

안녕하세요, 내 부모보기 컨트롤러 tabbar 컨트롤러입니다. didselect 행에서 새 tabbar 컨트롤러를로드하려고합니다. 그것을 수행하는 방법 – user1376474

+0

ur 부모보기 탭 막대 컨트롤러에 태그 값을주고 행을 선택하면 다른보기 컨트롤러로 이동합니다. tabcontroller보기 개체를 확인하고 태그 값의 도움으로 탭 막대를 제거합니다. cotroller보기 및 그 클래스의 새 탭 표시 줄 컨트롤러를 추가하십시오 – 08442

0

도움이 될이 같은 몇 가지 일을하려고 [당신이 시도 무엇]

UITabBarController *tabBarController = [[UITabBarController alloc]init]; 

    NSArray*tabBarimageArray=[NSArray arrayWithObjects:@"firstTabImage.png",@"secondTabImage.png", nil]; 




    YourFirstTabRootViewController *firstVc = [[YourFirstTabRootViewController alloc]initWithNibName:@"YourFirstTabRootViewController" bundle:nil]; 




    UINavigationController *firstNavigationController=[[UINavigationController alloc]initWithRootViewController:firstVc]; 


    YourSecondTabRootViewController *secondVc = [[YourSecondTabRootViewController alloc]initWithNibName:@"YourFirstTabRootViewController" bundle:nil]; 




    UINavigationController *secondNavigationController=[[UINavigationController alloc]initWithRootViewController:secondVc]; 


    NSArray *VCs = [[NSArray alloc] initWithObjects:firstNavigationController,secondNavigationController nil]; 
    NSArray *names = [NSArray arrayWithObjects: 
         NSLocalizedString(@"Tab1", @""), 
         NSLocalizedString(@"Tab2", @""), 

         nil]; 

    NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:[VCs count]]; 
    NSInteger index = 0; 


    for (id controller in VCs) { 




     UINavigationController * navController = controller ; 
       // THIS SETS UP THE TAB BAR ITEMS/IMAGES AND SET THE TAG FOR TABBAR_ITEM_TAGS 
       NSString *tabName = [names objectAtIndex:index]; 
       UIImage *tabImage = [UIImage imageNamed:[NSString stringWithFormat:[tabBarimageArray objectAtIndex:index]]]; 
       navController.title = tabName; 
       UITabBarItem *tempTab = [[UITabBarItem alloc] initWithTitle:tabName 
                     image:tabImage 
                     tag:index]; 
       navController.tabBarItem = tempTab; 

       [tabBarViewControllers addObject:navController]; 
     index ++; 

     } 





    [ tabBarController setViewControllers:tabBarViewControllers]; 

    [self presentModalViewController:tabBarController animated:YES]; 
+0

부모 탭 표시 줄을 숨기는 방법 ... – user1376474

관련 문제