帮助显示UITabBarController

时间:2011-04-06 21:45:34

标签: iphone ios4 uiviewcontroller uitabbarcontroller

我为我的应用程序创建了一个自定义Tabbarcontroller。现在我有一个uiview,在底部我想显示我的tabviewcontroller没有选择任何按钮。当用户按下任何按钮时,它将加载所选标签栏项目的相应视图。不知怎的,我的下面的代码不起作用。它显示一个白色的屏幕代替我的uiview屏幕,并且底部没有显示标签栏。

#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;
}

1 个答案:

答案 0 :(得分:0)

UITabBarController应该是你的父母。尝试将您的navigationController添加到您想要显示的选项卡上的tvControllers子视图中。 tvController.views = [NSArray arrayWithObjects:navigationController, someOtherController, nil];

要显示tableView,请将tableView添加到navigationController的视图中。