我有UITabBarViewController
包含4个单独的ViewControllers。每个VC在UIBarButtonItem
上都有一个NavigationBar
,可以带您进入" postPage"。您可以使用此代码进入帖子页面,该代码显示嵌入式NavigationController
- (void)postInvoked:(UIBarButtonItem *)sender
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *postPage = [storyboard instantiateViewControllerWithIdentifier: @"postPageLead"];
[self presentViewController:postPage animated:YES completion:nil];
}
然后在PostViewController.m
中,当用户点击IBAction
名为"后退"
UIBarButtonItem
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self.parentViewController.navigationController popViewControllerAnimated:YES];
}
这不起作用。请记住,一旦到达邮局,就不会记住呼叫VC。如何遍历原始调用ViewController
?(如何引用调用者,popViewControllerAnimated是必需的?)
答案 0 :(得分:8)
取而代之的是它,它应该可以正常工作。
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}
答案 1 :(得分:2)
我使用以下方法修复了它:
- (IBAction)backOnPost:(UIBarButtonItem *)sender
{
[self dismissViewControllerAnimated:YES completion:nil];
}