问题
I'm using REFrostedViewController
(https://github.com/romaonthego/REFrostedViewController) to show side menu in my app. Side menu works properly, but the problem is I have tabbar controller in content screen. Side menu has tableview with options to navigate. On tap of any options in side menu, am redirecting to viewcontrollers in another storyboards. I want the tabbar to be visible after selecting any option from Sidemenu.
This is how I'm assigning contentViewController
and menuViewController
in REFrostedViewController
derived class.
- (void)awakeFromNib {
self.contentViewController = [storyBoard instantiateViewControllerWithIdentifier:@"tabbarViewController"];
self.menuViewController = [storyBoard instantiateViewControllerWithIdentifier:@"menuViewController"];
}
In simple, I need the tabbar to be visible in all the screens. But when navigating from side menu, tabbar is not shown.
Below is the code in Sidemenu controller
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.frostedViewController.contentViewController = anotherControllerNavVC;
}
I can understand its because sidemenu class doesn't have instance of tabbar and the above line is replacing the content view controller. Anyone know how to achieve this with REFrostedViewController
.
I tried creating global instance of Tabbar controller. Below is my code
+ (instancetype)sharedInstance {
static TabController *tabbarVC = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
tabbarVC = [[super alloc] init];
});
return tabbarVC;
}
And in side menu
TabController *tabClassObj = [TabController sharedInstance];
[tabClassObj.selectedViewController pushViewController:newVC animated:YES];
来源:https://stackoverflow.com/questions/60278538/show-tabbar-from-refrostedviewcontroller-sidemenu-objective-c