返回PKRevealController时丢失左侧菜单

时间:2014-09-16 15:37:45

标签: ios objective-c storyboard

我正在现有项目中实施PKRevealController。该项目使用Storyboards,但用户可以在应用程序中玩Cocos2D 2.0游戏。

我的问题是,当用户离开Cocos2D时,我在我的导航控制器(控制Cocos2D游戏)上使用通知(通知中心)来切换到我的主视图,但是当它执行segue时{{1不再起作用了。

我在我的PKRevealController上实现了PKReveal,所以我想我应该(以某种方式)实现它,当我退出Cocos2d游戏时我可以重新实现它。

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:1)

如果有人遇到同样的问题,我就是这样解决这个问题的:

  • 在Storyboard中创建了一个新的UIViewController,并将其嵌入NavigationCotroller
  • 为这个新的ViewController创建了我的InitialViewController并实现了<PKRevealing, UIApplicationDelegate>
  • 在其中创建了这个属性:

    @property (nonatomic, strong) PKRevealController *revealController;
    @property (strong, nonatomic) UINavigationController *myNavController;
    @property (strong, nonatomic) UIWindow *window;
    
  • viewDidLoadself.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];(就像在AppDelegate上一样)

  • 最后在viewDidAppear方法:

    FrontViewController *frontViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"FrontViewController"];

    PortraitAppNavigationController *frontNavigationController = [[PortraitAppNavigationController alloc] initWithRootViewController:frontViewController];

    LeftMenuViewController *leftViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"LeftMenu"];

    // Step 2: Instantiate. self.revealController = [PKRevealController revealControllerWithFrontViewController:frontNavigationController leftViewController:leftViewController]; // Step 3: Configure. self.revealController.delegate = self; self.revealController.animationDuration = 0.25;

    // Step 4: Apply. self.window.rootViewController = self.revealController;

    [self.window makeKeyAndVisible];

相关问题