J'ai donc cherché partout des exemples pour créer un uitabbar prpgrammatically. J'ai fait de mon mieux pour prendre ce dont j'avais besoin à partir de chaque exemple et pour définir à quoi mon application ressemblerait: un écran de bienvenue après une barre d'onglets à 2 onglets.Impossible de faire apparaître mon uitabbar lors de sa configuration par programme
J'ai un contrôleur de vue de l'écran d'accueil avec une UIButton passer:
-(IBAction)aMethod:(id)sender {
MyTabProjectViewController *controller = [[MyTabProjectViewController alloc] initWithNibName:nil bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
Then in my MyTabProjectViewController.m I do this:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Setting up the view
UIView *contentView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
contentView.backgroundColor = [UIColor whiteColor];
self.view = contentView;
//Declaring all view controllers
FirstView *first = [[FirstView alloc] init];
SecondView *second = [[SecondView alloc] init];
//Set titles for the view controllers
first.title = @"First";
second.title = @"Second";
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.view.frame = CGRectMake(0, 0, 320, 460);
UINavigationController *nvc1 = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *nvc2 = [[UINavigationController alloc] initWithRootViewController:second];
nvc1.navigationBar.barStyle = UIBarStyleBlack;
nvc2.navigationBar.barStyle = UIBarStyleBlack;
NSArray *controllers = [[NSArray alloc] initWithObjects:nvc1, nvc2, nil];
self.tabBarController.viewControllers = controllers;
[self.view addSubview:tabBarController.view];
}
De rien une raison fonctionne. Quand je clique sur le bouton pour aller à MyTabProjectViewController, je vois une page blanche.
Je vois une fuite dans votre méthode, essayez de libérer le contrôleur [version du contrôleur]; après presentModal ... – Mat
en utilisant la collecte des ordures ... pas de fuites :) Merci! – TommyG
Vous devez le libérer, et je pense que vous devez appeler release sur contentView, premier, second, tabBarController, nvc1, nvc2, et les contrôleurs; Si vous instanciez un non-ivar, pourquoi ne le libérez-vous pas après l'avoir utilisé? – Mat