Left Side menu with TAbbar in iphone - ios

I want to implement the Left Side menu. On my top of screen, there is a TabBar with a menu button.
When the menu tab bar button click, the left Side menu will open.
I search a lot for this but all of them uses the Navigation Controller instead of TAbbar.
I try so many custom controls & SASlideview but don't understand how to work with tabbar.
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:[NSArray arrayWithObjects:[self navigationController],
[self navigationController], nil]];
SideMenuViewController *leftSideMenuController = [[SideMenuViewController alloc] init];
SideMenuViewController *rightSideMenuController = [[SideMenuViewController alloc] init];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:[self navigationController]
leftMenuViewController:leftSideMenuController
rightMenuViewController:rightSideMenuController];
self.window.rootViewController = container;
How can I do this?

Related

How to create a splitviewcontroller fron a view?

I am new in Xcode. I have viewcontroller with a navigation tabbar with items. I need that one on this menu item calls a splitview with master/detail. Is possible create a splitview in a view and not necessary in appdelegate? In appdelegate I have create one splitview, but if an option on menu.
Is possible to put this code in a the view that i clic the barbutton? The code used is:
detallContactesAccions = [[[CrmContactesAccionesDetallVC alloc] init] initWithNibName:#"CrmContactesAccionesDetallVC" bundle:nil];
masterContactesAccions = [[CrmContactesAccionesMasterTVC alloc] initWithStyle:UITableViewStylePlain];
masterContactesAccions.detailViewController = detallContactesAccions;
masterContactesAccions.navigationItem.title = NSLocalizedString(#"Acciones",#"");
UINavigationController *navMaster = [[[UINavigationController alloc] initWithRootViewController:masterContactesAccions] autorelease];
UINavigationController *navDetail = [[[UINavigationController alloc] initWithRootViewController:detallContactesAccions] autorelease];
splitViewController = [[UISplitViewController alloc] init];
//splitViewController.tabBarItem = controller.tabBarItem;
[splitViewController setValue:[NSNumber numberWithFloat:300.0] forKey:#"_masterColumnWidth"]; //Dóna més amplada a l'split view
splitViewController.viewControllers = [NSArray arrayWithObjects:navMaster, navDetail, nil];
splitViewController.delegate = detallContactesAccions;

add Navigation Bar to Tap bar

I want to have a common navigation bar to RecieptViewController and StockViewController and the bar should contain back button to go back to InventoryViewController.....
this code is written in InventoryViewController viewDidLoad:-
RecieptViewController *firstVC=[[RecieptViewController alloc]init];
UITabBarItem *itme1=[[UITabBarItem alloc]initWithTitle:#"First" image:nil tag:1];
itme1.title=#"Reciept";
[firstVC setTabBarItem:itme1];
StockViewController *secondView=[[StockViewController alloc]init];
UITabBarItem *item2=[[UITabBarItem alloc]initWithTitle:#"Second" image:nil tag:2];
item2.title=#"Stock";
[secondView setTabBarItem:item2];
[tapBarController setViewControllers:[NSArray arrayWithObjects:firstVC,secondView,nil]];
If you want to add navigation controllers to your UITabBarController then you must try the following:
UIViewController *viewController1, *viewController2;
UINavigationController *navigationController1, *navigationController2;
viewController1 = [[RecieptViewController alloc] initWithNibName:#"RecieptViewController" bundle:nil];
viewController2 = [[StockViewController alloc] initWithNibName:#"StockViewController" bundle:nil];
navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
navigationController2 = [[UINavigationController alloc] initWithRootViewController:viewController2];
[tapBarController setViewControllers:[NSArray navigationController1,navigationController2,nil]];

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

How to reorder TabBar's Tabs programmatically?

Is there a way to reorder tabs of a TabBar programmatically on xCode?
Thank you a lot, Matteo!
Try this:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
tabBarController = [[UITabBarController alloc] init];
MyViewController* vc1 = [[MyViewController alloc] init];
MyOtherViewController* vc2 = [[MyOtherViewController alloc] init];
NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil];
tabBarController.viewControllers = controllers;
// Add the tab bar controller's current view as a subview of the window
[window addSubview:tabBarController.view];
}

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