2016-05-21 11 views
-3

ホームスクリー後に最初にスプラッシュ画面が表示されるようにプロジェクトを開発する必要があります。そのホーム画面には、下部にTabbarが含まれています。いずれかをお勧めします。どうやって進める。私はプログラム的に必要ですObjective cのホームページにタブバーを追加

答えて

1

ストーリーボード代わりに使用することをお勧めします。

ViewController.hに:ViewController.mに

@property (nonatomic, retain) UITabBarController *tab; 

self.tab = [UITabBarController new]; 

// FirstViewController 
FirstViewController *vc1=[[FirstViewController alloc] initWithNibName:nil bundle:nil]; 
[email protected]"First View Controller"; 
vc1.tabBarItem.image = [UIImage imageNamed:@"viewcontroller1.png"]; 

//SecondViewController 
SecondViewController *vc2 = [[SecondViewController alloc]initWithNibName:nil bundle:nil]; 
[email protected]"Second"; 
vc2.tabBarItem.image = [UIImage imageNamed:@"viewcontroller2.png"]; 

self.tab.viewControllers = @[vc1, vc2]; 

[self.view addSubview:self.tab.view]; 
1

これはいくつかのナビゲーションコントローラを備えたタブバーをプログラム的に作成する方法です。しかし、私は強くあなたが特定のビューコントローラにタブバーを作成したい場合は、だから、

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    // Override point for customization after application launch. 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    //Alloc all the VC of the tab bar 
    UIViewController *firstViewController = [[UIViewController alloc] init]; 
    UIViewController *secondViewController = [[UIViewController alloc] init]; 
    UIViewController *thirdViewController = [[UIViewController alloc] init]; 

    //Create the tab bar 
    UITabBarController *tabBarController = [[UITabBarController alloc] init];   

    //Set the array of the tab bar with the VCs 
    tabBarController.viewControllers = @[firstViewController, secondViewController, thirdViewController]; 

    //create the navigation controller 
    UINavigationController *navigationController = [[UINavigationControlle alloc] initWithRootViewController:tabBarController]; 

    // init the app with the tab bar 
    self.window.rootViewController = tabBarController; 

    // 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
+0

私はUIViewControllerクラスをappdelegateクラスに書く必要はありません – vikramarkaios

+1

特定のビューのcoコントローラ?あなたはより良いあなたの疑問を特定するべきです。 –

+0

はい、私は特定のビューコントローラを実装する必要があります – vikramarkaios

関連する問題