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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With