REFrostedViewController icon indicating copy to clipboard operation
REFrostedViewController copied to clipboard

How to get current contentViewController and menuViewController

Open liuxuan30 opened this issue 10 years ago • 0 comments

I created rootVC inherit from REFrostedViewController and did the initialization in awakeFromNib, just like the demo.

Now In my SideBar view controller, I would like to jump to another View controller, and how to get the current rootVC object? I don't want to use instantiateViewControllerWithIdentifier just like in the demo to create new view controllers to achieve the jump, kind of waste to create such view controllers.

I am trying to use self.frostedViewController.contentViewController, but it seems like it returned a different view controller, not the rootVC.contentViewController

Code: @implementation RootViewController

  • (void)awakeFromNib { [super awakeFromNib]; self.contentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"]; self.menuViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"menuController"]; NSLog(@"Inited Conteng VC is: %@, menu VC is: %@", self.contentViewController, self.menuViewController); }
  • (IBAction)ShowHomeBtn:(id)sender { UINavigationController * naviVC = [self.storyboard instantiateViewControllerWithIdentifier:@"contentController"]; NSLog(@"new navi VC content VC is %@", naviVC); NSLog(@"current frosted content VC is %@", self.frostedViewController.contentViewController); HomeViewController *HomeVC = [self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"]; ( (UINavigationController *) self.frostedViewController.contentViewController).viewControllers= @[HomeVC]; [self.frostedViewController hideMenuViewController]; }

The log is: Inited Conteng VC is: UINavigationController: 0x7fb582e27750, menu VC is: SideBarController: 0x7fb582d8aef0

new navi VC content VC is UINavigationController: 0x7fb582c65b50

current frosted content VC is UINavigationController: 0x7fb582d9b1d0

liuxuan30 avatar Jan 15 '15 05:01 liuxuan30