how to add tabbar to uitableview - iphone

My app is Navigation base application.In this application , UIViewController has button event . Tap on Button firing to (pushViewController) CalendarTableview. Now i need to add Tabbar and tabitem to calendartableview . how to add Tabbar and tabitem to CalendarTableview. help me .
here is my picture.
Thanks.

UINavigationController has a built-in navigation-toolbar. Check the section in appples developer documentation, that should help if I understand your problem right.

In your calendartableview_controller's viewDidLoad() method, try to create a tab bar programmatically, and then add it as a subview to the view of your calendartableview_controller:
//create a tab bar controller in your calendartableview_controller
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.title = #"My Tab Bar";
//assign child controllers to the tab bar controller
tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, thirdViewController, nil];
//add it to your calendartableview_controller's view as a subview
[self.view addSubview:[tabBarController view]];

Related

Xcode: How to add new tab screen in IOS5 storyboard?

I have this..
How do I add another tab screen using iOS5 storyboard, so that "Account" can have 3 screens.
Account ---> Account Listing ---> Account Details
You first drop in a new ViewController, and then you Ctrl-drag from the Tab Bar Controller to that new controller.
This brings up a popup where you can select "Add Relationship Segue". This connects it as a third tab.
This can be done programmatically:
// Tab Controller
UITabBarController *tabBarController = [[UITabBarController alloc]init];
// Views to be accessed
UIViewController *controllerOne = [[UIViewController alloc]init];
UIViewController *controllerTwo = [[UIViewController alloc]init];
UIViewController *controllerThree = [[UIViewController alloc]init];
// Store UIViewControllers in array
NSArray* screenControllers = [NSArray arrayWithObjects:controllerOne, controllerTwo, controllerThree, nil];
// Add Views to Controller
tabBarController.viewControllers = screenControllers;
Or using InterfaceBuilder:
Adding 'Tab Bar Items' to the hierarchy of views in the left-hand panel
Or using Storyboard:
iOS Storyboards (Scroll down/Search for 'Just Add It To My Tab')

NavigationController Skip View

Is it possible to skip a view in a Navigation Controller? My structure is as follows:
**Main Screen Navigation Controller**
-Main Screen View
**Options Navigation Controller (Modal transition from Main Screen View)**
-Options Screen View
--Sub Options Screen View(Push from Options View)
On the first load of the application, I want to present a "Welcome" UIAlertView that will present the "Sub Options" screen.
Thanks
You'll have to build your navigation stack programmatically and then modally display the UINavigationController. Use the viewControllers property. The last view controller in the passed in array will become the top view controller.
OptionsViewController *ovc = [[OptionsViewController alloc] init];
SubOptionsViewController *sovc = [[SubOptionsViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] init];
nav.viewControllers = [NSArray arrayWithObjects:ovc, sovc, nil];
[self presentModalViewController:nav animated:YES];
Yes. If you read the documentation for UINavigationController, you'll see there's a method called setViewControllers:animated: that you can use to explicitly set the entire stack of view controllers at once.

Navigation-based app with TabBar

I'm using Navigation-based Application Template with Core Data. Could anyone please tell me how to and a TabBar on the bottom of the view. I am using UITableView, so If I add UITabBar as subview, the TabBar is moving along with tableView when scrolling. I would like to switch between views with TabBar, first "segment" of TabBar should open the RootView (NavigationBar with TableView),and second some other view.
Now I did this:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:yourNavigationController];
self.window.rootViewController = tabBarController
[tabBarController release];
that works fine, but how can I add more Items to UITabBar and for each Item some other view? TabBar has now just one Item on which rootView is loaded
Thanks!
Use UITabBarController as your root view controller in your application delegate:
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:yourNavigationController];
self.window.rootViewController = tabBarController
[tabBarController release];
Its simple one, just add UITabbarController to your code and then made the first tab controller to be a navigation controller. And point that navigation controller to your controller which has table view that you want to show.
If you are doing it programmatically you can use this:
FirstViewController *first=[FirstViewController alloc]]init];
UINavigationController *nav=[UINavigationController alloc]]initwithRootViewcontroller:first];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
tabBarController.viewController = [NSArray arrayWithObject:first];
[tabBarController release];

How to hide a tabbar at the app startup?

So, I want my app starts with a UIViewController(without seeing a tabbar), and then enter a UITableView with navigationbar and tabbar. the problem is that the Tabbar is visible at the app starts up, anyone can help on this will be very appreciated...
I think you should either send -presentModalViewController:animated: to your main UIViewController with the tab bar controller as an argument or just do this:
[myWindow addSubview: myTabBarController.view];
Make your app a navigation based application (rather than a tab bar based one) then add a tab bar on the UITableView.
There is help for adding the UITabBar here
I do it like this : in this case drawing a table view and map view (From the Locati application)
tabBarController = [[UITabBarController alloc] init]; // creates your tab bar so you can add everything else to it
searchTableViewController = [[SearchTableViewController alloc] init]; // creates your table view - this should be a UIViewController with a table view in it, or UITableViewController
UINavigationController *searchTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchTableViewController] autorelease];
[searchTableViewController release]; // creates your table view's navigation controller, then adds the view controller you made. Note I then let go of the view controller as the navigation controller now holds onto it
searchMapViewController = [[SearchMapViewController alloc] init];
UINavigationController *mapTableNavController = [[[UINavigationController alloc] initWithRootViewController:searchMapViewController] autorelease];
[searchMapViewController release]; // does exactly the same as the first round, but for your second tab at the bottom of the bar.
tabBarController.viewControllers = [NSArray arrayWithObjects:searchTableNavController, mapTableNavController, nil]; //add both of your navigation controllers to the tab bar. You can put as many controllers on as you like
I found this pattern a long time ago. Sorry that I can't point at the original.
YOu then need to add the tabbarcontoller to the relevant view ([...view addSubView:tabBarController];) possibly setting frame first.

TabBar combined with Navigation Bar / Search Bar and TableView

I used a TabBar in my iPhone application and integrated it programmatically.
I have several TabBarItems in it and every click will load a XYZ-ViewController with a corresponding XYZ-View.xib.
Now I use to have a screen with the TabBar and a NavBar with SearchBar and a segmented control like in this example of Apple:
http://developer.apple.com/iphone/library/samplecode/TableSearch/index.html
But in this example, there is not a TabBar and copy the source into my project causes the problem, that I did the loading in XViewController.m viewDidLoad method:
// Add create and configure the navigation controller.
MyAppDelegate *myAppDelegate = [[UIApplication sharedApplication] delegate];
// Add create and configure the navigation controller.
UINavigationController * navigationController = [[UINavigationControlleralloc] initWithRootViewController:self];
myAppDelegate.navController = navigationController;
[navigationController release];
[myAppDelegate.window addSubview:myAppDelegate.navController.view];
The effect is, that there is a toolbar with the correct title, but there is no searchbar and no TabBar at the bottom.
Could anyone give me a hint what's wrong here?
I solved the problem:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:test2ViewController];
NSArray* controllers = [NSArray arrayWithObjects:test1ViewController, navigationController, test3ViewController, nil];
[self.myTabBarController setViewControllers:controllers];