I have implemented this slide menu from library iOS Slide Menu and used the uitabbarcontroller.
Home viewcontroller is having this slidemenu but on click of side navigation bar slide bar menu is appear but on click of records any action not happen. Whereas if I use the this slidemenu without tabbarcontroller than it is working.
Anyone if implemented this slide menu under the uitabbarcontroller using the storyboard using objective C in IOS. Please share your answer.
In your code some of the changes I made like self.window.rootViewController
into App Delegate
.
Also I changed into the SlideNavigationController
define new UINavigationController
then give the Storyboard Id
that access into the code which is below.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
self.landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"launchingNVCtr"];
Also some code changes into the appDelegate
.
-(void)setupDrawers{
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
self.landingScreen = (SlideNavigationController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"launchingNVCtr"];
LeftMenuViewController *leftMenu = (LeftMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"LeftMenuViewController"];
RightMenuViewController *rightMenu = (RightMenuViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"RightMenuViewController"];
self.landingScreen = [SlideNavigationController sharedInstance];
self.landingScreen.rightMenu = rightMenu;
self.landingScreen.leftMenu = leftMenu;
self.landingScreen.menuRevealAnimationDuration = 0.18f;
// Creating a custom bar button for right menu
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
[button setImage:[UIImage imageNamed:@"gear"] forState:UIControlStateNormal];
[button addTarget:[SlideNavigationController sharedInstance] action:@selector(toggleRightMenu) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.landingScreen.rightBarButtonItem = rightBarButtonItem;
[[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);
}];
}
Then following method for calling when tap on Log In
button.
-(void)displayLandingScreen{
[self setupDrawers];
self.window.rootViewController = self.landingScreen;
}
Following code for when user tap on Log out
.
-(void)logOutPressed{
//mainTabBar
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone"
bundle: nil];
UITabBarController *loginTab = (UITabBarController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"mainTabBar"];
self.window.rootViewController = loginTab;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments