Tab Bar not hiding Using DDMenuController (Fb like sliding menu) - ios

I am facing this issue from last two days, but could find any solution on it. Can some one help. This is the code snippet am using for TabBar viewControllers.
// Set Up Tab Bar
NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:5];
self.tabBarController = [[UITabBarController alloc] init];
[tabBarController
setDelegate:self];
UINavigationController *navController = nil;
NSArray *vcArray = [self papulateViewControllers];
// SetViewController for tab Bar
-(NSArray *) papulateViewControllers{
BrowseViewController *browseVC = [[BrowseViewController alloc] initWithNibName:#"BrowseViewController" bundle:nil];
AlbumViewController *albumVC = [[AlbumViewController alloc] initWithNibName:#"AlbumViewController" bundle:nil];
SubmitStep1VC *submitVC = [[SubmitStep1VC alloc] initWithNibName:#"SubmitStep1VC" bundle:nil];
// SubmitStep1VC *submitVC = [[SubmitStep1VC alloc] initWithNibName:#"SubmitStep1_iPhone5.xib" bundle:[NSBundle mainBundle]];
WallViewController *wallVC = [[WallViewController alloc] initWithNibName:#"WallViewController" bundle:nil];
OptionVC *optionVC = [[OptionVC alloc] initWithNibName:#"OptionVC" bundle:nil];
sliderVCRef = [[SliderVC alloc] initWithNibName:#"SliderVC" bundle:nil];
//Navigation Controllers
UINavigationController *browseNavController = [[UINavigationController alloc] initWithRootViewController: browseVC];
[browseNavController setNavigationBarHidden:YES];
UINavigationController *albumNavController = [[UINavigationController alloc] initWithRootViewController: albumVC];
[albumNavController setNavigationBarHidden:YES];
UINavigationController *submitNavController = [[UINavigationController alloc] initWithRootViewController: submitVC];
[submitNavController setNavigationBarHidden:YES];
UINavigationController *wallNavController = [[UINavigationController alloc] initWithRootViewController: wallVC];
[wallNavController setNavigationBarHidden:YES];
UINavigationController *optionNavController = [[UINavigationController alloc] initWithRootViewController: optionVC];
[optionNavController setNavigationBarHidden:YES];
DDMenuController *browseMenuController = [[DDMenuController alloc] initWithRootViewController:browseNavController];
self.menuController = browseMenuController;
self.menuController.leftViewController = sliderVCRef;
DDMenuController *albumMenuController = [[DDMenuController alloc] initWithRootViewController:albumNavController];
albumMenuController.leftViewController = sliderVCRef;
DDMenuController *submitMenuController = [[DDMenuController alloc] initWithRootViewController:submitNavController];
submitMenuController.leftViewController = sliderVCRef;
DDMenuController *wallMenuController = [[DDMenuController alloc] initWithRootViewController:wallNavController];
wallMenuController.leftViewController = sliderVCRef;
DDMenuController *optionMenuController = [[DDMenuController alloc] initWithRootViewController:optionNavController];
optionMenuController.leftViewController = sliderVCRef;
/// Works fine if i uncomment this line and comment next line of code (Passing Viewcontrollers is fine )
// return [NSArray arrayWithObjects:self.menuController, albumVC, submitVC, wallVC, optionVC, nil];
////******* issue in case i use this line (Passing menuController creates issue of Tabbar )
return [NSArray arrayWithObjects:self.menuController, albumMenuController, submitMenuController, wallMenuController, optionMenuController, nil];
////////////
}
When i try to push to push to any viewcontroler from any above TabBarController Tab bar is not hiding . example
grandPrizeVC.hidesBottomBarWhenPushed = YES;
Its keep showing me tab bar.
If i try
appDelegate.tabbarcontroller.tabbar.hidden = YES; It shows on a black bottom bar on new VC.

Your app doing just what you have implemented. You are adding your sliding menu view controller as subview controller to tabbar controller, of course, it won't hide. Some suggestions to hide tabbar:
1. Add tabbar controller as modal to your DDMenuController
2. write some methods to hide/show tabbar (searching hide tabbar will give you the answers, or you could just traverse subviews of tabbar controller's view find tabbar and hide it).
Good luck!

Following worked for me :
Show TabBar :
+ (void) showTabBar{
MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
UITabBar *tabBar = appDelegate.tabBarController.tabBar;
UIView *parent = tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
CGRect tabFrame = tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds) - CGRectGetHeight(tabBar.frame);
tabBar.frame = tabFrame;
CGRect contentFrame = content.frame;
contentFrame.size.height -= tabFrame.size.height;
}
Hide TabBar:
+(void) hideTabBar{
MyAppDelegate* appDelegate = (MyAppDelegate *) [[UIApplication sharedApplication]delegate];
UITabBar *tabBar = appDelegate.tabBarController.tabBar;
UIView *parent = tabBar.superview; // UILayoutContainerView
UIView *content = [parent.subviews objectAtIndex:0]; // UITransitionView
UIView *window = parent.superview;
[UIView animateWithDuration:0.01
animations:^{
CGRect tabFrame = tabBar.frame;
tabFrame.origin.y = CGRectGetMaxY(window.bounds);
tabFrame.origin.y +=20;
tabBar.frame = tabFrame;
content.frame = window.bounds;
}];
}

Related

iOS 9.0 Tabbar hide automatically and viewcontroller disappear in push

I have a TabBarController with 4 Tab. When i push a ViewController from a tab then the tab is hidden automatically and its showing nothing in View. But ViewController contains a tableview with data. I have implemented tableview delegate also.I am not getting tableview delegate logs.
in appdelegate didFinishLaunchingWithOptions()
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.homeScreen = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.rootNav = [[UINavigationController alloc]initWithRootViewController:self.homeScreen];
self.window.rootViewController = self.rootNav;
[self.window makeKeyAndVisible];
Load TabBar here:
myAppDelegate.myTabBarController.selectedIndex = 0;
myAppDelegate.myTabBarController.tabBar.translucent = NO;
myAppDelegate.myTabBarController.tabBar.opaque = YES;
location_select *tab1 = [[location_select alloc] initWithNibName:#"location_select" bundle:nil];
tab1.tabBarItem.image = [UIImage imageNamed:#"Restaurants.png"];
location_select *tab2 = [[location_select alloc] initWithNibName:#"location_select" bundle:nil];
tab2.title = #"Cart";
tab2.tabBarItem.image = [UIImage imageNamed:#"Cart.png"];
Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:#"Deal_ViewController" bundle:nil];
tab3.title = #"Deals";
tab3.tabBarItem.image = [UIImage imageNamed:#"Deals.png"];
MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:#"MoreViewController" bundle:nil];
tab4.title = #"More";
tab4.tabBarItem.image = [UIImage imageNamed:#"More.png"];
myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:tab1,tab2,tab3,tab4,nil];
[myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];
From Tab 4, i push Profile_ViewController:
Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:#"Profile_ViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:vc animated:YES];
And already i applied there:
myAppDelegate.myTabBarController.hidesBottomBarWhenPushed=NO;
and
[self.tabBarController setHidesBottomBarWhenPushed:NO];
in viewWillAppear of Profile_ViewController. Nothings works. I just see a blank white screen.
location_select *tab1 = [[location_select alloc] initWithNibName:#"location_select" bundle:nil];
tab1.tabBarItem.image = [UIImage imageNamed:#"Restaurants.png"];
location_select *tab2 = [[location_select alloc] initWithNibName:#"location_select" bundle:nil];
tab2.title = #"Cart";
tab2.tabBarItem.image = [UIImage imageNamed:#"Cart.png"];
Deal_ViewController *tab3 = [[Deal_ViewController alloc] initWithNibName:#"Deal_ViewController" bundle:nil];
tab3.title = #"Deals";
tab3.tabBarItem.image = [UIImage imageNamed:#"Deals.png"];
MoreViewController *tab4 = [[MoreViewController alloc] initWithNibName:#"MoreViewController" bundle:nil];
tab4.title = #"More";
tab4.tabBarItem.image = [UIImage imageNamed:#"More.png"];
UINavigationController *nav1 = [[UINavigationController alloc] initWithRootViewController:tab1];
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:tab2];
UINavigationController *nav3 = [[UINavigationController alloc] initWithRootViewController:tab3];
UINavigationController *nav4 = [[UINavigationController alloc] initWithRootViewController:tab4];
myAppDelegate.myTabBarController.viewControllers = [NSArray arrayWithObjects:nav1,nav2,nav3,nav4,nil];
[myAppDelegate.rootNav pushViewController:myAppDelegate.myTabBarController animated:YES];
and then later on to push your vc to tab 4 you should do
Profile_ViewController *vc = [[Profile_ViewController alloc] initWithNibName:#"Profile_ViewController" bundle:[NSBundle mainBundle]];
[nav4 pushViewController:vc animated:YES];
here is the Solution related to your query which might help you
You might have kept your architecture as follows
Navigation Controller ---> Tab bar Controller --> 4 child View Controllers
You need to do this
Tab bar Controller --> 4 Child controllers(Each of these 4 child View Controller having its own Navigation Controller).

Navigation Bar not showing title

I am unable to get the navigation bar to show the title that I specify. I have tried to change the title in the AppDelegate.m, as well as in the viewDidLoad of my first tab view. I suspect the title is being hidden, but I am unable fix it. Please provide any insight you may have.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[CRGradientNavigationBar class] toolbarClass:nil];
UIColor *firstColor = [UIColor colorWithRed:155.0f/255.0f green:41.0f/255.0f blue:104.0f/255.0f alpha:1.0f];
UIColor *secondColor = [UIColor colorWithRed:215.0f/255.0f green:90.0f/255.0f blue:18.0f/255.0f alpha:1.0f];
NSArray *colors = [NSArray arrayWithObjects:firstColor, secondColor, nil];
[[CRGradientNavigationBar appearance] setBarTintGradientColors:colors];
self.navigationController.title = #"This title is not showing";
[[navigationController navigationBar] setTranslucent:NO];
//create the view controller for the first tab
self.firstViewController = [[FirstViewController alloc] initWithNibName:nil
bundle:NULL];
//create the view controller for the second tab
self.secondViewController = [[SecondViewController alloc] initWithNibName:nil
bundle:NULL];
//create the view controller for the third tab
self.thirdViewController = [[ThirdViewController alloc] initWithNibName:nil
bundle:NULL];
//create the view controller for the fourth tab
self.fourthViewController = [[FourthViewController alloc] initWithNibName:nil
bundle:NULL];
//create an array of all view controllers that will represent the tab at the bottom
NSArray *myViewControllers = [[NSArray alloc] initWithObjects:
self.firstViewController,
self.secondViewController, self.thirdViewController, self.fourthViewController, nil];
//initialize the tab bar controller
self.tabBarController = [[MainUITabBarController alloc] init];
//set the view controllers for the tab bar controller
[self.tabBarController setViewControllers:myViewControllers];
[navigationController setViewControllers:#[self.tabBarController]];
[self.window setRootViewController:navigationController];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
The relationship of your view controllers isn't right.
The root view controller of your app should be the TabBarController.
Each of the items should have it's own Navigation Controller.
The title of each ViewController can be set in viewDidLoad() with self.title = "....
I've been able to set titles in the delegate as follows:
1.) Create view controllers
2.) Set those titles
3.) Then create UINavigationControllers and assign view controllers there
self.firstViewController = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
self.secondViewController = [[SecondViewController alloc] initWithNibName:nil bundle:nil];
self.thirdViewController = [[ThirdViewController alloc] initWithNibName:nil bundle:nil];
self.fourthViewController = [[FourthViewController alloc] initWithNibName:nil bundle:nil];
[self.firstViewController setTitle:#"First"];
[self.secondViewController setTitle:#"Second"];
[self.thirdViewController setTitle:#"Third"];
[self.fourthViewController setTitle:#"Fourth"];
UINavigationController *controller1 = [[UINavigationController alloc] initWithRootViewController:self.firstViewController];
UINavigationController *controller2 = [[UINavigationController alloc] initWithRootViewController:self.secondViewController];
UINavigationController *controller3 = [[UINavigationController alloc] initWithRootViewController:self.thirdViewController];
UINavigationController *controller4 = [[UINavigationController alloc] initWithRootViewController:self.fourthViewController];
NSArray *viewControllers = [NSArray arrayWithObjects:controller1, controller2, controller3, controller4, nil];

uiview issue with tab bar

I am working on Xcode 5.1.2 iOS7.My problem is that i want to implement tab bar controller on second view controller . Tab bar controller is implemented successfully.My all view are slightly transparent which inserts in array to tab bar.when i click on tab bar button,first view is visible at behind of every view of tab bar views.so how i can solve this problem.
tabbar=[[UITabBarController alloc]init];
UIViewController *first=[[ViewController alloc]init];
UIViewController *second=[[SearchViewController alloc]init];
UIViewController *third=[[Party_partner_ViewController alloc]init];
UIViewController *Fourth=[[My_GrooveViewController alloc]init];
UIViewController *Fifth=[[More_ViewController alloc]init];
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:first];
UINavigationController *firstNavController1 = [[UINavigationController alloc] initWithRootViewController:second];
UINavigationController *firstNavController2 = [[UINavigationController alloc] initWithRootViewController:third];
UINavigationController *firstNavController3 = [[UINavigationController alloc] initWithRootViewController:Fourth];
UINavigationController *firstNavController4 = [[UINavigationController alloc] initWithRootViewController:Fifth];
NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:#"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
self.nav.navigationBar.barTintColor = [UIColor colorWithRed:29/255.0f green:29/255.0f blue:29/255.0f alpha:1.0f];
self.nav.navigationBar.translucent = NO;
}else
{
self.nav.navigationBar.tintColor = [UIColor colorWithRed:29/255.0f green:29/255.0f blue:29/255.0f alpha:1.0f];
}
self.nav.navigationBar.topItem.title = #"The Groove";
tabbar.viewControllers=[NSArray arrayWithObjects:firstNavController,firstNavController1, firstNavController2,firstNavController3,firstNavController4, Nil];
AppDelegate *mainDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
// UIWindow *window= [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[mainDelegate.window addSubview:tabbar.view];
sure first you can hide or remove your uiview

how to add tab bar controller from the second view controller [duplicate]

This question already has an answer here:
Showing login view controller before main tab bar controller
(1 answer)
Closed 9 years ago.
Im beginner to IOS app development learning.
I have a login screen as my first view controller and i need the second view controller to be a tab bar view controller .with 4 different tabs and i have 4 different XIB's for them.
some one help me to go ahead.
Best way you can do is Present the login screen modally when the app starts from your tab bar controller first screen, add code for presenting login screen in viewWillAppear and after login dismiss the screen. You can create TabBarController in appDelegate like this
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController tabBarController=[[UITabBarController alloc] init];
FirstViewController *firstVC = [[UIViewController alloc] initWithNibName:#"FirstVC" bundle:nil];
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController: firstVC];
SecondViewController *secondVC = [[UIViewController alloc] initWithNibName:#"secondVC" bundle:nil];
UINavigationController *secondNavController = [[UINavigationController alloc] initWithRootViewController:secondVC];
tabBarController.viewControllers = [NSArray arrayWithObjects: firstNavController, secondNavController, nil];
tabBarController.selectedIndex=0;
tabBarController.delegate = self;
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTitle:#"Movies" image:[UIImage imageNamed:#"MoviesTAB.png"] tag:1];
[firstVC setTabBarItem:item1];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTitle:#"Music" image:[UIImage imageNamed:#"musicTAB.png"] tag:2];
[seconfVC setTabBarItem:item2];
tabController.tabBar.translucent = NO;
tabController.tabBar.barStyle = UIBarStyleBlack;
tabBarController.tintColor = [UIColor whiteColor];
self.window.rootViewController = tabController;
return YES;
}
Best way is use storyboard and there just have one initial UIViewController and from that make segue to UITabBarViewController.
http://youtu.be/a_DCTSTv1Mw
If you want to make it through xib make a UITabBarViewController and add viewControllers to the array of object of that UITabBarViewController's object.
Sample code :
NSMutableArray *arrViewControllers = [[NSMutableArray alloc] init];
UIViewController *tabController;
UIImage *tabImage ;
NSString *tabTitle;
for (int i= 0; i < 3; i++) {
switch (i) {
case 0:
tabController = [[ViewController alloc] init];
tabImage = [UIImage imageNamed:#"icon1.png"];
tabTitle = #"Text";
break;
case 1:
tabController = [[ImageDemoViewController alloc] init];
tabImage = [UIImage imageNamed:#"icon2.png"];
tabTitle = #"Image";
break;
case 2:
tabController = [[TableDemoViewController alloc] init];
tabImage = [UIImage imageNamed:#"icon3.png"];
tabTitle = #"Table";
break;
}
// set the image and title using some properties of UIViewController
tabController.tabBarItem.image = tabImage;
tabController.tabBarItem.title = tabTitle;
//add objects to array
[arrViewControllers addObject:tabController];
[tabController release];
}
_baseController = [[UITabBarController alloc] init];
_baseController.viewControllers = arrViewControllers;
[arrViewControllers release];
go to your appDelegate
1.create a viewController for login screen.
LoginViewController *viewController1 = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
2.create a navigationController with root view your login ViewController.
UINavigationController *nVC = [[UINavigationController alloc] initWithRootViewController:viewController1];
3.make navigationController to root view of window.
self.window.rootViewController = self.nVC;
[self.window makeKeyAndVisible];
Now go to Touch-Up-Inside method of login button in LoginViewController.
1.After validation of password and userId initialise your viewControllers for tabbar and TabbarViewController.
UiViewController ...*yourViewControllers,..,
UITabBarController *YourtabBarController = [[UITabBarController alloc] init];
2.Now add these viewControllers to your tabbarController.
YourtabBarController.viewControllers = #[ YourViewController1,YourViewController2,YourViewController3,......];
3.Finally push this tabbarController to navigationControllere.
[self.navigationController pushViewController:YourtabBarController animated:NO];

iPad Navigation controller in splitview popover frame issue

I put a navigation controller as Split-view root-view controller.
When the iPad is in Portrait mode the root view controller is displayed inside a popover controller. Its by default I know....
But My problem is The top of root-view controller is seems hide by popover. See the attched image. In it the home bar-button seems hide a small portion in top.
RootViewController *objRootViewController = [[RootViewController alloc] init];
DetailViewController *objDetailViewController = [[DetailViewController alloc] init];
UINavigationController *rootNavigationController = [[UINavigationController alloc] initWithRootViewController:objRootViewController];
UINavigationController *detailNavigationController = [[UINavigationController alloc] initWithRootViewController:objDetailViewController];
UISplitViewController *objSplitViewController = [[UISplitViewController alloc] init];
[objSplitViewController setDelegate:objDetailViewController];
[objSplitViewController setViewControllers:[NSArray arrayWithObjects:rootNavigationController,detailNavigationController, nil]];
self.splitViewController = objSplitViewController;
[self.window addSubview:self.splitViewController.view];
[objSplitViewController release];
objSplitViewController = nil;
[rootNavigationController release];
rootNavigationController = nil;
[detailNavigationController release];
detailNavigationController = nil;
[objDetailViewController release];
objDetailViewController = nil;
[objRootViewController release];
objRootViewController = nil;

Resources