Objective c 如何从链接的情节提要场景向父级UINavigationController添加按钮? 我的设置

Objective c 如何从链接的情节提要场景向父级UINavigationController添加按钮? 我的设置,objective-c,ios7,uinavigationcontroller,swrevealviewcontroller,Objective C,Ios7,Uinavigationcontroller,Swrevealviewcontroller,在一个主故事板中,我使用了一个带有不同部分链接的侧边栏 每个部分都在一个单独的故事板中表示,该故事板在主故事板中链接为 如果在子情节串连图板中,我在主导航控制器中执行场景分段,它就能够通过放置目标场景标题和后退按钮来表示这一点。在这一点上,一切都很好 模式的近似值为: -SWRevealViewController |-> (SWRevealViewControllerSegue) -> sw_front |-> (SWRevealViewControllerSegue)

在一个主故事板中,我使用了一个带有不同部分链接的侧边栏

每个部分都在一个单独的故事板中表示,该故事板在主故事板中链接为

如果在子情节串连图板中,我在主导航控制器中执行场景分段,它就能够通过放置目标场景标题和后退按钮来表示这一点。在这一点上,一切都很好

模式的近似值为:

-SWRevealViewController
 |-> (SWRevealViewControllerSegue) -> sw_front
 |-> (SWRevealViewControllerSegue) -> sw_rear

-(sw_rear)UITableViewController
 |(each row selection)
 |-> SWRevealViewControllerSegue -> (CommonContainer)

-CommonContainer
 |-> Container -> Embed segue for container -> RBStoryboardLink

- RBStoryboardLink
 |->(User defined runtime attributes) "storyboardName" : "target_storyboard"

-SpecfificControllerOfTargetedStoryboard
 -(void)viewDidLoad{
    UIBarButtonItem * button = //...
    self.topViewController.navigationItem.rightBarButtonItem = button;//DOESN'T WORK
我的问题 我无法从子故事板将RightBarButtonims添加到主导航栏

- (void) addRightButton:(UIBarButtonItem *) button{
    self.topViewController.navigationItem.rightBarButtonItem = button;
}
我尝试过但没有成功 使用singleton动态添加BarButton 我已经使主navigationcontroller成为一个单例,并使用一个方法添加从不同故事板的子场景传递的按钮

- (void) addRightButton:(UIBarButtonItem *) button{
    self.topViewController.navigationItem.rightBarButtonItem = button;
}
这仅在第一次工作时有效,即使在菜单上调用根场景时也是如此

缩小主导航栏的范围
最糟糕的解决方案,也不起作用。我无法更改主导航栏的宽度以显示子场景的顶部按钮。

我以这种不优雅的方式解决了我的问题:

在CommonContainer或specific container中,我添加了所需的Nagiviation项,并关联了一个iAction目标,该目标发送由所需故事板的特定UIViewController接收的消息

-CommonContainer
 |-> Container -> Embed segue for container -> RBStoryboardLink
 |-(void)viewDidLoad{
     UIButton *rightButton = [[UIButton alloc] initWithFrame: CGRectMake(0, 0, 15, 13)];
     [rightButton setBackgroundImage:[UIImage imageNamed:@"mv-white-setting.png"] forState:UIControlStateNormal];
     [rightButton setTitle:@"" forState:UIControlStateNormal];
     [rightButton addTarget:self action:@selector(rightTopBarButtonAction:) forControlEvents:UIControlEventTouchUpInside];
     UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
     self.navigationController.topViewController.navigationItem.rightBarButtonItem = rightButtonItem;
 }
 |- (IBAction)rightTopBarButtonAction:(id)sender {
     [[NSNotificationCenter defaultCenter] postNotificationName:@"movements_rightTopBarButtonAction" object:nil];
 }

- RBStoryboardLink
 |->(User defined runtime attributes) "storyboardName" : "target_storyboard"

-SpecfificControllerOfTargetedStoryboard
 |-(void)viewDidLoad{
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rightButtonAction:) name:@"movements_rightTopBarButtonAction" object:nil];