我正在尝试更改现有设置以使用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实现到我当前的实现中?
答案 0 :(得分: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;
}
}
这对我很有用。希望这对你也有帮助。