1

Je suis affichant une UITableViewController à l'intérieur d'un UITabBarController qui est présenté de façon modale:Les éléments de navigation dans UITableViewController n'apparaissent pas?

-(IBAction)arButtonClicked:(id)sender{ 

    //this is a uitableviewcontroller 
    ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease]; 

    LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease]; 
    lbViewController.title = @"Leaderboard"; 

    arTabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil]; 
    arTabBarController.viewControllers = [NSArray arrayWithObjects:arViewController, lbViewController, nil]; 
    arTabBarController.selectedViewController = arViewController; 

    [self presentModalViewController:arTabBarController animated:YES]; 
} 

Dans mon viewDidLoad pour la méthode arViewController Je suis en train de les éléments de navigation:

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    // Uncomment the following line to preserve selection between presentations. 
    self.clearsSelectionOnViewWillAppear = NO; 
    self.title = @"AR"; 

    leaderBoardButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize 
                    target:self 
                    action:@selector(leaderBoardButtonClicked:)]; 

    self.navigationItem.rightBarButtonItem = leaderBoardButton; 

} 

Ma barre de navigation qui ne fonctionne pas apparaît quand il est à l'intérieur de l'UITabBarController, mais quand je pousse la vue elle-même, je suis capable de le voir.

Qu'est-ce qui me manque?

Répondre

0

je devais ajouter un UINavigationBar:

ARViewController* arViewController = [[[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]autorelease]; 
    UINavigationController *arNavController = [[UINavigationController alloc] initWithRootViewController:arViewController]; 

    LeaderBoardTableViewController* lbViewController = [[[LeaderBoardTableViewController alloc] initWithNibName:@"LeaderBoardTableViewController" bundle:nil]autorelease]; 
    lbViewController.title = @"Leaderboard";  
    UINavigationController *lbNavController = [[UINavigationController alloc] initWithRootViewController:lbViewController]; 

    arTabBarController = [[UITabBarController alloc] init];//initWithNibName:nil bundle:nil]; 
    arTabBarController.viewControllers = [NSArray arrayWithObjects:arNavController, lbNavController, nil]; 
    arTabBarController.selectedViewController = arNavController; 

    [self presentModalViewController:arTabBarController animated:YES]; 
+1

dammut, manqué par 6 secondes :( – Rudiger

2

Heh, j'ai déconcerté par cela aussi. Ce que vous devez faire est d'envoyer le rootViewController.

Je ne l'ai jamais utilisé un tabBar pour quoi que ce soit, sauf sur l'écran mais ur code ressemblera probablement à ceci:

après arTabBarController.selectedViewController = arViewController;

UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController: arTabBarController] autorelease]; 
[self presentModalViewController: navController animated:YES]; 

Comme je l'ai dit que je ne l'ai pas fait avec un tabBar mais je suis sûr que ce sera quelque chose le long de ces lignes

0

Il y a une solution simple, mettre mise en vue apparaît

-(void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 

    [self.navigationController setNavigationBarHidden:NO animated:animated]; 
} 

espérons que cela aidera certains débutants;

Questions connexes