0

我正在尝试更改我现有的设置以使用 SlidePanel。滑动面板来自这里的 JA:- https://github.com/gotosleep/JASidePanels

我的现有代码如下: App Delegate 确实完成了启动:

welcomeViewController = [[MySpyWelcomeViewController alloc] initWithNibName:@"MyWelcomeViewController" bundle:nil];

navController = [[UINavigationController alloc] initWithRootViewController:welcomeViewController];
navController.navigationBarHidden = YES;

self.viewController = self.navController;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

用户登录后,我将调用一个推送 Home 视图控制器的方法:

// Push the homeViewController onto the navController
NSLog(@"presentHomeViewController");
self.navController.navigationBarHidden = NO;
[self.navController setTitle:@"Home"];
[self.navController pushViewController:self.homeViewController animated:NO];

在 JA 幻灯片面板示例中,它显示以下内容:

self.viewController = [[JASidePanelController alloc] init];
self.viewController.leftPanel = [[JALeftViewController alloc] init];
self.viewController.centerPanel = [[UINavigationController alloc] initWithRootViewController:[[JACenterViewController alloc] init]];
self.viewController.rightPanel = [[JARightViewController alloc] init];

self.window.rootViewController = self.viewController;

我不确定如何将其实现到我当前的布局中,因为滑动面板将其视为视图控制器而不是导航控制器。有谁知道我如何将 JASlidePanel 实现到我当前的实现中?

4

1 回答 1

1

在您的 appdelegate.h 文件中执行以下操作:

    @class JASidePanelController;

然后

   //just generally declare the JAsidepanelcontroller
    @property (nonatomic,retain) JASidePanelController *homeViewController;
   //This is your loginviewcontroller
    @property (nonatomic,retain) LoginMainController *loginmainController;

然后在您的 appdelegate.m 文件中执行以下操作:

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
     {

        if(loggedin)
       {
         if (!self.homeViewController) {

        MySpyWelcomeViewController *mySpyWelcomeViewControllerTemp = [[MySpyWelcomeViewController alloc] init];
        UINavigationController *navigationControllerTemp = [[UINavigationController alloc] initWithRootViewController:mySpyWelcomeViewControllerTemp];
        self.navigationController = navigationControllerTemp;

     //here use the left and right viewcontroller that you are going to show for the sidemenu
        SidebarOptionsLeftViewController *sidebarOptionsleftViewControllerTemp = [[SidebarOptionsLeftViewController alloc] init];
        SidebarOptionsRightViewController *sidebarOptionsrightViewControllerTemp = [[SidebarOptionsRightViewController alloc] init];
        sidebarOptionsrightViewControllerTemp.delegate = mySpyWelcomeViewControllerTemp;

        JASidePanelController *homeViewTemp = [[JASidePanelController alloc] init];
        homeViewTemp.shouldDelegateAutorotateToVisiblePanel = NO;

        homeViewTemp.leftPanel = sidebarOptionsleftViewControllerTemp;
        homeViewTemp.centerPanel = navigationControllerTemp;
        homeViewTemp.rightPanel = sidebarOptionsrightViewControllerTemp;
      }
        self.window.rootViewController = self.homeViewController;
      }

   else {
    if (!self.loginmainController) {
        LoginMainController *loginmainControllerTemp = [[LoginMainController alloc] initWithNibName:@"LoginMainController" bundle:nil];
        self.loginmainController = loginmainControllerTemp;
    }
    if (!self.navigationController) {
        UINavigationController *navigationControllerTemp = [[UINavigationController alloc] initWithRootViewController:self.loginmainController];
        self.navigationController = navigationControllerTemp;
        self.navigationController.navigationBarHidden = YES;
    }
    self.window.rootViewController = self.navigationController;
  }

}

这对我很有效。希望这对你也有帮助。

于 2012-12-03T13:47:22.993 回答