问题
I am trying to add a persistent button at the bottom of view via UIContainerView in storyboard on SlidenavigationController.
But I am getting a blank view on navigation of left slide out(where as it is working fine with list of table contents on left slide out with out the container View) (used a third party Tool with iOS-Slide-Menu )
Storyboard
Code for mainPageViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
[[ParseServiceManager GetInstance] initializeParse];
[SlideNavigationController sharedInstance].leftMenu = [[UINavigationController alloc] initWithRootViewController:[[LeftMenuViewController alloc] init]];;
[SlideNavigationController sharedInstance].rightMenu = [[UINavigationController alloc] initWithRootViewController:[[RightMenuViewController alloc] init]];
[SlideNavigationController sharedInstance].menuRevealAnimationDuration = .18;
[SlideNavigationController sharedInstance].enableSwipeGesture = FALSE;
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidClose object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Closed %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidOpen object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Opened %@", menu);
}];
[[NSNotificationCenter defaultCenter] addObserverForName:SlideNavigationControllerDidReveal object:nil queue:nil usingBlock:^(NSNotification *note) {
NSString *menu = note.userInfo[@"menu"];
NSLog(@"Revealed %@", menu);
}];
}
Warning in Console as:
SlideNavigationController has not been initialized. Either place one in your storyboard or initialize one in code
If any one have faced similar issue to initialise the Slide-navigation in CustomViewController instead of App delegate, please help me in solving this!
回答1:
I didn't add any UiNavigationController(SlidenavigationController) in Storyboard Plz refer screenshot but initialized Programmatically like this below
Push LoginView with SlideNavigationController from Appdelegate
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
LoginViewController *loginView = (LoginViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"LoginViewController"];
[loginView setModalPresentationStyle:UIModalTransitionStyleCrossDissolve];
SlideNavigationController * slideNavCtl = [[SlideNavigationController alloc] initWithRootViewController:loginView];
[self.window setRootViewController:slideNavCtl];
Push HomeView with SlideNavigationController from Appdelegate
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
HomeViewController *homeView = (HomeViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:@"HomeViewController"];
[homeView setModalPresentationStyle:UIModalTransitionStyleCrossDissolve];
SlideNavigationController * slideNavCtl = [[SlideNavigationController alloc] initWithRootViewController:homeView];
[self.window setRootViewController:slideNavCtl];
LeftMenuViewController *leftMenu2 = (LeftMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
[SlideNavigationController sharedInstance].leftMenu = leftMenu2;
After LOGIN from LOGINVIEW I will push to HOMEVIEW view with LeftMenuViewController or SideBarViewController like this
if(Login){
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle: nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier: @"HomeViewController"];
-----This is Important ,You need assign ur LeftMenu or SidebarViewcontroller here-----------------
LeftMenuViewController *leftMenu2 = (LeftMenuViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
[SlideNavigationController sharedInstance].leftMenu = leftMenu2;
------------------------------
[[SlideNavigationController sharedInstance] pushViewController:vc animated:YES];
}else {
nslog(@"Login Update failed")
}
来源:https://stackoverflow.com/questions/35264600/issue-in-adding-uicontainerveiw-to-slideviewnavigation-in-storyboard-ios