2016-05-21 5 views
-3

Ich muss für mein Projekt für zuerst kommenden Splash-Screen nach dann Home Geröll entwickeln. In diesem Startbildschirm befindet sich die Registerkarte auf der Unterseite. Bitte schlagen Sie irgendeinen vor. Wie geht es weiter? Ich brauche programmatischAdd Tabbar in Startseite in Objective c

Antwort

1

zu verwenden, wenn Sie einen Tabbar auf einem bestimmten View-Controller erstellen möchten:

auf ViewController.h:

@property (nonatomic, retain) UITabBarController *tab; 

auf ViewController.m

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

So erstellen Sie programmatisch eine Tab-Leiste mit einigen Navigations-Controllern darin. Aber ich empfehlen dringend So Drehbuch Stelle

- (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

Ich muss UIViewController Klasse nicht in Appdelegate Klasse – vikramarkaios

+1

auf eine bestimmte Ansicht co schreiben Kinderwagen? Sie sollten Ihre Zweifel besser angeben. –

+0

ja, ich muss spezifische Ansicht Controller implementieren – vikramarkaios