Reputation: 5071
The practical solution of my problem is to present a UINavigationController modally that has a UINavigationBar at the top containing a title and a left bar button with the title @"Done" that will dismiss the modal UINavigationController.
For whatever reason, I cannot figure out how to successfully implement this. I understand this is not the traditional use for a UINavigationController and i'm sure it's a simple solution but I cannot figure it out.
What I have tried is this:
ABPersonViewController *personVC = [ABPersonViewController personControllerWithCard:card];
personVC.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(ClosePeoplePicker)];
testerVCF = [[UINavigationController alloc] initWithRootViewController:personVC];
[self presentViewController:testerVCF animated:TRUE completion:^
{
NSLog(@"Completed");
}];
When I execute this code, a UINavigationController is presented but with no title and with no Done button.
Might you have a suggestion? I just don't think i'm thinking in line with how a UINavigationContoller operates.
Thanks in advance.
Upvotes: 2
Views: 397
Reputation: 606
The problem is you're setting the navigation controller's barButton items, and title in the wrong place. What you should do instead is
Upvotes: 2
Reputation: 19862
If your main view controller is UIViewController than you should read that:
Especially that part:
- (void) displayContentController: (UIViewController*) content
{
[self addChildViewController:content]; // 1
content.view.frame = [self frameForContentController]; // 2
[self.view addSubview:self.currentClientView];
[content didMoveToParentViewController:self]; // 3
}
- (void) hideContentController: (UIViewController*) content
{
[content willMoveToParentViewController:nil]; // 1
[content.view removeFromSuperview]; // 2
[content removeFromParentViewController]; // 3
}
Upvotes: 0