Frage

ich hoffe, jemand kann mir explane, wie dies zu tun:

Ich habe eine TabBar und zwei TabBarItems, wie kann ich die Einzelteile der TabBar attatch. Ich bin nicht diese über IB zu tun, weil die TabBar nur fits des Bildschirms haben, weil die Elemente auf der linken Seite sein sollte.

das ist, wie ich sie bauen:

tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController2 = [[UITabBarController alloc] initWithNibName:nil bundle:nil];

tabBarController.tabBar.frame = CGRectMake(0, 974, 384, 50);    
tabBarController2.tabBar.frame = CGRectMake(384, 974, 384, 50);

UITabBarItem *tbi1 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
UITabBarItem *tbi2 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1];
War es hilfreich?

Lösung

Sie können Tab-Leiste Elemente direkt in der Tab-Leiste gesetzt. Stattdessen weisen Sie eine Tab-Leiste Element in die tabBarItem Eigenschaft für jeden View-Controller von der Tab-Leiste Controller enthalten. Dann, wenn Sie Ihre Ansicht-Controller auf die Tab-Leiste Controller hinzufügen, wird die Tab-Leiste Controller die Anzeige Ihrer Tableiste Elemente für Sie verwalten.

UITabBarController * tabBarController = [[UITabBarController alloc] init];

UIViewController * viewController1 = [[YourViewController alloc] init];
UIViewController * viewController2 = [[YourOtherViewController alloc] init];

viewController1.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:0];
viewController2.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMostViewed tag:1];

tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top