tabbar with navigation controller iphone application - iphone

I have created a tabbar with navigation bar iphone application and i added another view which is coming from home tab.The view is coming but the navigation bar and tabbar are not coming.why?

Go in your application's delegate, find the method didFinishLaunchingWithOptions:.
Make sure you set the
self.window.rootViewController = self.tabBarController;
(where tabBarController is your tabbar controller - obviously).
Make sure you have the following line right before the end of the method:
[self.window makeKeyAndVisible];
Check your main .nib file (MainWindow.xib, probably) and make sure that at least the first TabBar item contains a navigation controller - which opens your view (the one you mentioned).
Hope you sort it out, good luck !

Related

Push a view on top of a SplitViewController on launch

I have a SplitViewController for my iPad application and I want to push a screen on top of it when it launches so I can have a login screen. The problem is that I have not been able to get a screen to hide the main and detail screen.
I can not use addsubview since the rootview is not hidden.
Well you can do this simple thing, make loginview controller rootview controller
In application:didFinishLaunchingWithOptions: make
self.window.rootViewController = self.loginViewController
and on successful login make your splitviewcontroller root view controller
appDelegate.window.rootViewController = appDelegate.splitViewController
To do this type of thing you would have to create your own implementation of a SplitViewController. One popular implementation is MGSplitViewController.

XCode 4 (iPhone) Navigation in sub views

I'm in the process of creating an application for the iPhone for a client of ours and I'm stuck. Basically the application has a homepage (so to speak) which is simply a grid of (custom) buttons that when pressed takes you through to a specific part of the application. The home page is fairly plain with no navigation or tab bars displaying. However the majority of the other areas require navigation that will start at the point the area is first entered for instance I click from the home page into an area and from there I could click further into the app and at any point I can use the navigation controller to get all the way back to the first page of that area.
I've written a couple of test apps that use navigation and seen many examples while trying to figure this out but they all have the Navigation Controller implemented in the App Delegate and then display it in the Main Window but I don't want it to be displayed in the first view.
Firstly, is what I'm trying to do possible? (I suspect it is because most things are). And secondly what is the preferred way of achieving it? Any help would be much appreciated.
you can use a Navigation Controller even for the root level, then show/hide the navigation bar as necessary when you push or pop items on the navigation stack.
You should look into the -setNavigationBarHidden:animated: method on UINavigationController, which you could call in -viewWillAppearAppear: and -viewWillDisappear or in the navigation controller's delegate.
If your "Home Page" is just a UIViewController, you can present a UINavigationController modally which will allow you to navigate through to different areas. From your "Home Page" I would call the following:
NextViewController *nextView= [[[NextViewController alloc] initWithNibName:nil bundle:nil] autorelease];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:modalViewController];
[self presentModalViewController:navigationController animated:YES];

iPhone Obj C - 2nd XIB How to configure a Nav Controller and View Controller

Still learning Obj-C slowly... forgive the dumb questions...
On my 1st XIB I have the App Delegate, Nav Controller and several view controllers. Along with that I have several buttons that calls a 2nd or 3rd or subsequent XIB.
The subsequent XIBS all have buttons which display views.
So on the 2nd+ XIB I have configured it in the .h as an UIViewController however I am guessing I need to make it something else like the primary .h is an AppDelgate.
So right now the XIB wants the view set, but I don't want it to go to a view, I want it to go to the view controller... I think??
Maybe I am still going about this all wrong. I need the primary menu to call the next menu (2nd XIB) which in turn calls various views. In my Java Android app I have about 70 classes, and guess and about 45 views so I am guessing again that I do in fact need the multiple XIBS.
So the question is how do I set up the additional XIBs? Are they AppDelegates or what?
Does that change the way I call the 2nd XIB?
The XIBs or the UIViews (or it's subclasses) are just the facial make up.
For the actually programming part, you deal directly among the "controllers" classes for these views.
View controllers that you make can have an XIB attached to them. But the behavior of how and when the view is shown or hidden, is all handled by the view controller itself.
So to come to the point, if you want to have a navigation bar on the top of you app (assuming that it's a simple app wanting to show many views with a navigation bar):
Create a UINavigationController instance in your applicationDidFinishLaunching: method in the app delegate:
// Assuming that mainViewController is the first controller + view for your app.
navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
[window addSubview:navigationController.view];
This will automatically add a navigation bar to your views. You don't need to add them manually in XIB or anywhere else. Now how you draw/implement mainViewController, is up to you.
When you want to show another view from within mainViewController, you should call:
AnotherViewController *anotherViewController = [[[AnotherViewController alloc] init] autorelease];
[self.navigationController pushViewController:anotherViewController animated:YES];
This will "push" your new view (from anotherViewController instance) into your navigation structure, which will automatically add a back button on the top.
Hope this helps clear the scene of how it works, a bit.
If you have doubts, comment about it. Have a great day!

How to implement a view to be shown before a Tab Bar Controller?

I am designing an iPhone app in which when the application first launches, it should show a login/password view that is not part of Tab Bar Controller. Once the user enters a valid password, they are taken to a standard Tab View with a Tab Bar as the root controller. My challenge is whether to do a Window-based application or to do a Tab Bar application when I first start the project.
I hope I am making sense.
Thank you
You can start with a Tab Bar app just fine.
In your appDelegate's application:didFinishLaunchingWithOptions: method, right at the end, you'll add the login screen's viewController and pop it up on top of the tabs by simply adding two lines, like so:
[window addSubview:tabcontroller.view]; // Already present
initialScreenViewController = [[InitialScreenViewController alloc] init];
[window addSubview:initialScreenViewController.view];
[window makeKeyAndVisible]; // Already present
return YES; // Already present
Because you're adding the initialScreenViewController (call it whatever you want, that's just an example) after the tab bar, it will appear above it (closer to the screen) in the window. When you're done with it you can dismiss it and your tabs and such will all be present.
Edited to add
Here's how to add it modally:
Instead of
[window addSubview:initialScreenViewController.view];
use
[self.tabBarController presentModalViewController:initialScreenViewController animated:NO];
[initialScreenViewController release];

How are the 2 View Controllers wired to the tabBarController in iPhoneRecipes

I am learning iPhone programming by reviewing the iPhone Recipes sample application.
I am puzzled with how the two view controllers are wired to the tab bar. If they are wired in the XIB, can anyone explain how it is done or where I can get more visually aided details on connecting things in the XIBs.
This is my starting point in the learning process:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
recipeListController.managedObjectContext = self.managedObjectContext;
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
Basically, the view property of the tab bar is being added as a subview of the window.
The view property of the tab bar points at the tab bar's visual component, (the tab bar view itself) and the tab bar controller handles its behaviour (changing tabs, etc).
Each individual tab is a subview of the tab bar, so when the tab bar view is added as a subview of the window, its subviews are brought along for the ride. It's a little tricky to get your head around at first, but it should start sinking in after youplay around with interface builder a bit more.
All that's happening in the XIB is you're setting the view outlets on each tab so that they can be displayed when each tab is selected.
Hope this helps.