我的设置
在主情节提要中,我使用SWRevealViewController作为侧边栏,其中包含指向不同部分的链接。
每个部分都表示在一个单独的故事板中,该故事板在主故事板中使用RBStoryboardLink 链接。
如果在子情节提要中,我对主导航控制器的场景执行 segues,则它能够表示这放置目标场景标题和后退按钮。在这一点上,一切正常。
模式的近似值是:
-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
我的问题
我无法从子故事板将 rightBarButtonItems 添加到主导航栏。
我尝试过但没有成功
使用单例动态添加条形按钮
我已经使主导航控制器成为一个单例,并使用一种方法来添加从不同故事板的子场景传递的按钮。
- (void) addRightButton:(UIBarButtonItem *) button{
self.topViewController.navigationItem.rightBarButtonItem = button;
}
这仅在第一次有效,即使在菜单上调用根场景时也是如此。
缩小主导航栏
最糟糕的解决方案,也不起作用。我无法更改主导航栏宽度以显示子场景顶部按钮。