Domanda

Spero che qualcuno mi può esplicativi, come fare questo:

Ho un TabBar e due TabBarItems, come posso attatch gli oggetti al TabBar. Non sto facendo questo tramite IB perché la barra delle linguette solo si adatta hanno dello schermo perché gli articoli dovrebbero essere sul lato sinistro.

thats come costruisco loro:

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];
È stato utile?

Soluzione

Non c'è impostare le voci barra delle schede direttamente nella barra delle schede. Invece, si assegna un oggetto scheda bar per la proprietà tabBarItem per ciascun controller della vista contenuta dal controller barra delle schede. Poi, quando si aggiungono i controller di vista al controller barra delle schede, il controller barra delle schede gestirà la visualizzazione dei tuoi articoli barra delle schede per voi.

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];
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top