ios - 更改 UINavigation Controller 以与 SlidePanel 配合使用

标签 ios ios5 uiview uiviewcontroller uinavigationcontroller

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

我现有的代码如下: 应用程序委托(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];

用户登录后,我将调用一个推送主页 View Controller 的方法:

// 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;

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

最佳答案

在您的 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;
  }

这对我来说效果很好。希望这对您也有帮助。

关于ios - 更改 UINavigation Controller 以与 SlidePanel 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13032595/

相关文章:

ios - 在不分派(dispatch)到主队列的情况下更新 UI 元素

objective-c - iOS 5 Newsstandkit在哪里存储下载的问题?

ios - MPNowPlayingInfoCenter 和 MPRemoteCommandCenter 在模拟器中工作,但在设备上不起作用

iphone - 类型名称未知Iphone错误

ios - SwiftUI 删除 View 上的空格

android - iOS相当于增加堆大小

javascript - 防止 iOS 5.1 上打开键盘的默认操作

objective-c - 在 iOS 中使用 JSON 创建动态表单

ios - 如何制作内容可滚动和重用样式的屏幕?

ios - Apple 是如何在 Apple Music 中制作专辑封面背后的模糊效果的?