Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation controller in modal view

Currently, when a button is tapped, a UIModalPresentationSheet comes up. I'd like to add a navigation bar at the top of this when it slides up. I've tried a lot of things but nothing seems to work. Here's what i'm currently trying and it returns this error.

    AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete];
    //[self.navigationController pushViewController:addAthlete animated:YES];

    addAthlete.delegate = self;
    addAthlete.modalPresentationStyle = UIModalPresentationFormSheet;
  //  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addAthlete];
    [self presentViewController:navigationController animated:YES completion:nil];

But it pushes it up modally, and without the modalpresentationsheet form. How can I make it so the navigation controller is sized correctly?

like image 777
Josue Espinosa Avatar asked Oct 04 '13 13:10

Josue Espinosa


1 Answers

Try to change your code like this :

    AthleteAdd *addAthlete = [self.storyboard instantiateViewControllerWithIdentifier:@"addAthlete"];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addAthlete];

    addAthlete.delegate = self;
    navigationController.modalPresentationStyle = UIModalPresentationFormSheet;


    [self presentViewController:navigationController animated:YES completion:nil];

Because here, you try to present addAthlete from itself. So you get this error.

like image 75
Jordan Montel Avatar answered Nov 01 '22 05:11

Jordan Montel