2011-04-06 102 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的视图。