2011-04-06 100 views
0

我爲我的應用程序創建了一個自定義Tabbarcontroller。現在我有一個uiview,在底部我想顯示我的tabviewcontroller沒有選擇任何按鈕。當用戶按下任何按鈕時,它將加載所選擇的tabbar項目的相應視圖。不知何故,我的下面的代碼不起作用。它會顯示一個白色屏幕來代替我的uview視圖,並且不會在底部顯示一個tabbar。幫助顯示UITabBarController

#import <UIKit/UIKit.h> 
#import "UICustomTabViewController.h" 

@interface AssignmentViewController : UIViewController<UITabBarDelegate, UITableViewDelegate,UITableViewDataSource> { 
    NSMutableArray *listAssignments; 
    NSMutableArray *staffImages; 
    UICustomTabViewController *tabViewController; 
    } 

@property (nonatomic, retain) UICustomTabViewController *tabViewController; 

@end 
- (void)viewDidLoad { 


    UICustomTabViewController *tvController = [[UICustomTabViewController alloc] initWithNibName:@"TabViewController" bundle:nil]; 

    self.tabViewController = tvController; 

    [self.view addSubview:tvController.view]; 

    listAssignments = [[NSMutableArray alloc] init]; 
    staffImages = [[NSMutableArray alloc] init]; 

    //Add items 
    [listAssignments addObject:@"TRANSPORTATION"]; 
    [listAssignments addObject:@"ROOMS"]; 
    [listAssignments addObject:@"FOOD & BEVERAGES"]; 

    //Set the title 
    self.navigationItem.title = @"ASSIGNMENTS"; 

    [super viewDidLoad]; 
     [tvController release]; 

} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    tableView.separatorColor=[UIColor grayColor]; 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
    } 


    // Configure the cell. 
    cell.textLabel.textColor=[UIColor blackColor]; 
    cell.textLabel.text=[listAssignments objectAtIndex:indexPath.row]; 
    cell.textLabel.font=[UIFont systemFontOfSize:16]; 
    return cell; 
} 

回答

0

UITabBarController應該是你的父母。嘗試將您的navigationController添加到您想要顯示的選項卡上的tvControllers子視圖。 tvController.views = [NSArray arrayWithObjects:navigationController, someOtherController, nil];

要顯示tableView,需要將tableView添加到navigationController的視圖。