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に追加します

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

TabBarVC.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 に答える
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 に答える