Dans iOS, la propriété TabBar dans TabBarController est en lecture seule. Comment puis-je associer un élément personnalisé à un contrôleur de vue particulier? Comment puis-je accéder à UITabBarItems à l'intérieur du tabBar?Définir UITabBarItem personnalisé par programme?
Vous aimez cette
CustomView *custom = [[CustomView alloc] init];
UITabBarItem *customTab = [[UITabBarItem alloc] initWithTitle:@"Custom" image:[UIImage imageNamed:@"custom.png"] tag:0];
SecondView *second = [[SecondView alloc] init];
UITabBarItem *secondTab = [[UITabBarItem alloc] initWithTitle:@"Next" image:[UIImage imageNamed:@"next.png"] tag:1];
NSArray *views = [NSArray arrayWithObjects:custom,second,nil];
[tabBarController setViewControllers:views];
//how do I set the individual TabBarItems (customTab,secondTab) to be associated
//with the views in question? tabBarController.tabBar is read only
Essayer de modifier tabBar avec tabBar: setItems: animated est un non-no. *** Termination de l'application en raison d'une exception non interceptée 'NSInternalInconsistencyException', raison: 'La modification directe d'une barre d'onglets gérée par un contrôleur de barre d'onglets n'est pas autorisée.' – Justin