【发布时间】:2011-04-06 21:45:33
【问题描述】:
我为我的应用程序创建了一个自定义的 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;
}
【问题讨论】:
标签: iphone ios4 uiviewcontroller uitabbarcontroller