0

标题基本概括了所有内容。我正在尝试创建一个界面,在与 Facebook 连接后,窗口会加载我的HomeViewController(我最初选择的UITabBarItem)。虽然,我不希望UINavigationBar通过,因为我已将 设置HomeViewControllerLoginViewController的根视图。我为每个视图都有不同的导航栏项目,所以默认为那个是行不通的。我现在有这个代码。

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.mainViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.mainViewController];
    self.window.rootViewController = self.navigationController;
}
4

2 回答 2

0

经过一夜好眠后,我能够弄清楚。希望这可以帮助其他人!

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.tabBarController = [[UITabBarController alloc] init];

    // Initialize view controllers
    HomeViewController *homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    ConnectViewController *connectViewController = [[ConnectViewController alloc] initWithNibName:@"ConnectViewController" bundle:nil];
    PartyControlViewController *partyControlViewController = [[PartyControlViewController alloc] initWithNibName:@"PartyControlViewController" bundle:nil];
    MeViewController *meViewController = [[MeViewController alloc] initWithNibName:@"MeViewController" bundle:nil];
    MoreViewController *moreViewController = [[MoreViewController alloc] initWithNibName:@"MoreViewController" bundle:nil];

    [self.tabBarController setViewControllers:[NSArray arrayWithObjects:homeViewController, connectViewController, partyControlViewController, meViewController, moreViewController, nil]];

    // Customize Tab Bar
    UITabBarItem *homeTab = [[UITabBarItem alloc] initWithTitle:@"Home" image:nil tag:0];
    UITabBarItem *connectTab = [[UITabBarItem alloc] initWithTitle:@"Connect" image:nil tag:1];
    UITabBarItem *partyControlTab = [[UITabBarItem alloc] initWithTitle:@"Party Control" image:nil tag:2];
    UITabBarItem *meTab = [[UITabBarItem alloc] initWithTitle:@"Me" image:[UIImage imageNamed:@"person.png"] tag:3];
    UITabBarItem *moreTab = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:4];

    [homeViewController setTabBarItem:homeTab];
    [connectViewController setTabBarItem:connectTab];
    [partyControlViewController setTabBarItem:partyControlTab];
    [meViewController setTabBarItem:meTab];
    [moreViewController setTabBarItem:moreTab];

    self.window.rootViewController = self.tabBarController;
}
于 2012-12-05T18:48:08.820 回答
0

创建您的自定义标签栏类将其添加到 appDelegate

appDelegate.m

self.tabBarVC = [[[TabBarVC alloc] init] autorelease];
self.navController = [[[UINavigationController alloc]initWithRootViewController:self.tabBarVC]autorelease]; 
self.window.rootViewController = self.navController;

TabBarVC.h

#import <UIKit/UIKit.h>

@interface TabBarVC : UITabBarController


@end

标签栏VC.m

#import "TabBarVC.h" 
#import "ViewController1.h" 
#import "ViewController2.h"


@implementation TabBarVC


 - (void)viewDidLoad
{
    [super viewDidLoad]; 

    UIViewController *vc1 = [[UIViewController alloc] initWithNibName:@"ViewController1" bundle:nil];


    UIViewController *vc2 = [[UIViewController alloc] initWithNibName:@"ViewController2" bundle:nil];

    [self setViewControllers:[NSArray arrayWithObjects:vc1,vc2, nil]];  


}

@end
于 2012-12-05T08:11:02.817 回答