在我的项目中,我使用SWRevealviewcontroller作为滑块菜单。当Project在后台时,然后Foreground那时我想要当前的前视图对象。


如何从SWRevealviewcontroller获取当前的前视图控制器?


 - (void)applicationWillEnterForeground:(UIApplication *)申请{

 SWRevealViewController * mainRevealController = [[SWRevealViewController alloc] init];

 NSLog(@“front:%@”,mainRevealController.frontViewController);
 }
 代码>


答案 0 :(得分:0)
- (void)applicationDidBecomeActive:(UIApplication *)application
{
UIWindow *window=[UIApplication sharedApplication].keyWindow;
UIViewController *root = [window rootViewController];
UIStoryboard *storyboard = root.storyboard;
CustomViewController *vcc =(CustomViewController *) [storyboard instantiateViewControllerWithIdentifier:@"storyBoardID"];
[root presentModalViewController:vcc animated:YES];
}
当你的应用程序变为活动状态时,将ViewController传递给前端,此方法存在于appdelegate中