2011-03-22 3 views
0

하이, iRestaura 프로젝트를 기반으로 탭을 만들었습니다. 5 개의 탭 표시 줄 항목을 사용합니다. Tabbar 이름 중 하나는 Customer입니다. 고객을 탭할 때 또 다른 tabbar는 프로그래밍 방식으로 3 개의 viewcontroller로 생성됩니다. 뷰 didload 메서드를 사용하면 tabbarcontroller가 성공적으로 생성됩니다. 하지만 난보기 didAppear 다음 tabbar 컨트롤러 tabbar 만들어지지 않습니다. 두 경우 모두 프로그래밍 방식으로 생성 된 다른 세 viewcontroller보기가 작동하지 않는 것 같지 않습니다. 하지만 모든 경우에 viewDidAppear 메서드를 사용해야합니다. Plz은 누군가가 나를 도울 수 ... 울부 짖는 소리 주어진다 작동하지 viewDidAppear 방법 .....ViewDid가 작동하지 않는 것처럼 보입니다. xcode

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    UITabBarController *tabBarController1=[[UITabBarController alloc] init]; 

    CustomerListViewController *customerListViewController=[[CustomerListViewController alloc] init]; 
    [email protected]"Customer List"; 
    UIImage *anImage1 = [UIImage imageNamed:@"customer.png"]; 
    UITabBarItem *theItem1 = [[UITabBarItem alloc] initWithTitle:@"CustomerList" image:anImage1 tag:0]; 
    customerListViewController.tabBarItem = theItem1; 


    SelectedCustomerViewController *selectedCustomerViewController= [[SelectedCustomerViewController alloc] init]; 
    [email protected]"Selected Customer"; 
    UIImage *anImage3 = [UIImage imageNamed:@"selectedCustomer.png"]; 
    UITabBarItem *theItem = [[UITabBarItem alloc] initWithTitle:@"Selected Customer" image:anImage3 tag:1]; 
    selectedCustomerViewController.tabBarItem = theItem; 

    InvoiceListViewController *invoiceListViewController=[[InvoiceListViewController alloc] init]; 
    [email protected]"Invoice List"; 
    UIImage *anImage2 = [UIImage imageNamed:@"invoiceNo.png"]; 
    UITabBarItem *theItem2 = [[UITabBarItem alloc] initWithTitle:@"Invoice List" image:anImage2 tag:2]; 
    invoiceListViewController.tabBarItem = theItem2; 

    NSMutableArray *controllers=[[NSMutableArray alloc] init]; 
    [controllers addObject:customerListViewController]; 
    // [controllers1 addObject:vc1]; 
    [controllers addObject:selectedCustomerViewController]; 

    [controllers addObject:invoiceListViewController]; 
    ///[controllers1 addObject:vc4]; 
    tabBarController1.viewControllers=controllers; 

    [self.navigationController setNavigationBarHidden:YES animated:YES]; 
    [[self view] addSubview:tabBarController1.view]; 
    for (int t=0; t<[controllers count]; t++) 
    { 
     NSLog(@"controller%@",[controllers objectAtIndex:t]); 
    } 

} 

답변

0

이 시도 :

은 첫째로 당신의 TabBar의 컨트롤러하는 .m 파일에 아래의 기능을 사용 :

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{ 
    [viewController viewWillAppear:YES]; 
} 

그리고 TabBar의 컨트롤러하는 .m 파일의 당신의 "viewDidLoad에"기능에

, "localNavigationController.delegate = 자기;"사용을 사용한다.

UserListing *nearBy = [[UserListing alloc] init]; 
nearBy.tabBarItem.image = [UIImage imageNamed:@"icoTabNearby.png"]; 
nearBy.tabBarItem.title = @"Nearby"; 
localNavigationController = [[UINavigationController alloc] initWithRootViewController:nearBy]; 
localNavigationController.delegate = self; 

희망 하시겠습니까?

+0

하이, 답 감사합니다. 사실 나는 이것을 시도했다. 이건 내 고객 탭에 대한 작업이지만 여기에 내가 다른 3 uiview 컨트롤러를 고객에서 만들고 있어요. t –

+0

"localNavigationController.delegate = self;"를 사용해야합니다. 모든 뷰 컨트롤러에 대해 개별적으로 – Prabh

관련 문제