Dismiss it like this instead and it should work fine.
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
Frage
I have a UITabBarViewController
containing 4 individual ViewControllers. Each VC has a UIBarButtonItem
on their NavigationBar
to take you to a "postPage". You get to the post page by using this code, which presents the embedded NavigationController
- (void)postInvoked:(UIBarButtonItem *)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *postPage = [storyboard instantiateViewControllerWithIdentifier: @"postPageLead"];
[self presentViewController:postPage animated:YES completion:nil];
}
Then in the PostViewController.m
, I have an IBAction
that is triggered when the user clicks the UIBarButtonItem
named "Back":
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self.parentViewController.navigationController popViewControllerAnimated:YES];
}
This isn't working.. Keep in mind that the calling VC isn't remembered once you arrive at the postpage. How do I traverse back to the original calling ViewController
?(how do I reference the caller, and is popViewControllerAnimated: necessary?)
Lösung
Dismiss it like this instead and it should work fine.
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
Andere Tipps
I fixed it using:
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}