0

我添加了代码来制作具有导航功能的标签栏应用程序。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization




        ChatVC *objChatVC = [[ChatVC alloc]init];
        UpdateMeContactVC *objUpdateMeContact = [[UpdateMeContactVC alloc]init];
        cardsVC *objCardsVC = [[cardsVC alloc]init];
        settingVC *objSettingVC = [[settingVC alloc]init];
        NotificationVC *objNotificationVC = [[NotificationVC alloc]init];

        self.objNavConChat = [[UINavigationController alloc]initWithRootViewController:objChatVC];
        self.objNavConContact = [[UINavigationController alloc]initWithRootViewController:objUpdateMeContact];
        self.objNavConCards = [[UINavigationController alloc]initWithRootViewController:objCardsVC];
        self.objNavConNotification = [[UINavigationController alloc]initWithRootViewController:objNotificationVC];
        self.objNavConSetting = [[UINavigationController alloc]initWithRootViewController:objSettingVC];
        self.objTabBarController = [[UITabBarController alloc]init];

        self.objNavConChat.title = @"Chat";
        self.objNavConContact.title = @"Contacts";
        self.objNavConCards.title = @"Cards";
        self.objNavConNotification.title = @"Notification";
        self.objNavConSetting.title = @"Setting";

        self.objNavConChat.tabBarItem.image = [UIImage imageNamed:@"online_chat.png"];
        self.objNavConCards.tabBarItem.image = [UIImage imageNamed:@"card.png"];
        self.objNavConContact.tabBarItem.image = [UIImage imageNamed:@"contact.png"];
        self.objNavConNotification.tabBarItem.image = [UIImage imageNamed:@"notification.png"];
        self.objNavConSetting.tabBarItem.image = [UIImage imageNamed:@"settings.png"];


        objTabBarController.viewControllers = [NSArray arrayWithObjects:objNavConChat,objNavConCards,objNavConContact,objNavConNotification,objNavConSetting, nil];
        objTabBarController.selectedIndex=2;
        [self.view addSubview:self.objTabBarController.view];





    }
    return self;
}

在 updatemecontact 中,我使用的是滚动视图上的 tableview,我的 xib 是 3.5 英寸,但是当我运行程序时,tabbar 不起作用。我无法在 tabbar 上选择任何选项。

4

1 回答 1

8

转到 MainWindow.xib,选择 Window 对象并检查“启动时全屏”。

在此处输入图像描述

于 2012-11-26T08:04:45.020 回答