如何将后退按钮的目的地更改为另一个故事板 iOS?

How to change destination of back button to another storyboard iOS?

我的申请流程如下:

  1. 主故事板:导航 A -> ViewController A1(我的应用程序的第一个屏幕)...转到某些屏幕并转到其他故事板。

  2. 第二个故事板:导航 B -> ViewController B1 -> ViewController B2 -> ViewController B3.

我在 B3 时的正常逻辑,点击后退按钮返回 B2,然后再次点击返回 B1 ...
现在我想通过单击后退按钮从 B3 转到 A1。我使用此代码

UIStoryboard *Main = [UIStoryboard storyboardWithName:@"Main" bundle:nil];


UIViewController *theTabBar = (UIViewController *)[Main instantiateViewControllerWithIdentifier:@"PageController"];

[self.navigationController pushViewController:theTabBar animated:YES];

但它并没有像我想要的那样工作(在 Main 上出现了后退按钮,那是错误的),我将 pushViewController 更改为 popViewController 但它也没有工作。

就在b3的后退按钮上的这段代码:-

[[NSNotificationCenter defaultCenter] postNotificationName:@"takeBack" object:nil];

并在 A1 的视图 viewwillappear 上编写此代码:-

-(void)viewWillAppear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(popping) name:@"takeBack" object:nil];
}
-(void)popping{
    NSUInteger index=-1;

    for (UIViewController *view in [self.navigationController viewControllers]) {
        if ([view isKindOfClass:[self class]]) {
            index=[[self.navigationController viewControllers] indexOfObject:view];
        }
    }

    [self.navigationController popToViewController:[[self.navigationController viewControllers] objectAtIndex:index] animated:YES];

}