【问题标题】:Help with displaying UITabBarController帮助显示 UITabBarController
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 2012-03-26
      • 1970-01-01
      • 1970-01-01
      • 2010-11-19
      • 2020-05-06
      • 1970-01-01
      相关资源
      最近更新 更多