Help with displaying UITabBarController
i have created a custom Tabbarcontroller for my application. now i have a uiview where at the bottom i want to display my tabviewcontroller without any buttons selected. And when the user presses on any button it will then load the corresponding view of the tabbar item selected. Somehow my below code doesnt work. it displays a white screen in place of my uiview screen and doesnt display a tabbar at the bottom.
#import <UIKit/UIKit.h>
#import "UICustomTabViewController开发者_StackOverflow中文版.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;
}
UITabBarController should be your parent. Try to add your navigationController to your tvControllers subview at the tab you want it to show. tvController.views = [NSArray arrayWithObjects:navigationController, someOtherController, nil];
To show a tableView, you add the tableView to your navigationController's view.
精彩评论