I've used [[self navigationController] setTitle:#"Test Title"] to no avail. This is the same way I do it in the rest of my app. What could cause this?
Try setting the title of the navigation item.
self.navigationItem.title = #"Test Title";
Or like this if you prefer
[[self navigationItem] setTitle:#"Test Title"];
You are using the title property incorrectly, the navigationController has a title property because it inherets from UIViewController, the title property is used by NavigationControllers to display a title, so if you wanted the title you gave your NavigationController to show you would need to present it in another NavigationCOntroller...But what you need to do, is set the viewControllers that you are displaying titles instead of the NavigationController, now whenever u display that VC youll see the title in the navigation bar...
In short...the viewcontrollers title property is used by its navigationController to display the title on the navigation bar when that viewcontroller is on the top of the navigation stack...
CustomViewController *viewController = [[CustomViewController alloc] init];
[viewController setTitle:#"CustomViewController!";
[custonNavigationController pushViewController:viewController animated:YES];
This is a simplification of what Daniel had said. This method properly follows stack protocol.
SecondViewController *s1=[[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
[s1 setTitle:#"Second Page"];
[self pushViewController:s1 animated:YES];
Worked for me.
Related
Just as the title says, I have a UINavigationController nested in a UITabBarController. When the user taps on a table cell, I would like to push a view controller (which doesn't show the UITabBar). This is the behavior of the iPod app when you tap on "Now Playing."
How can this be done?
Just add this in the view controller you are pushing.
- (BOOL)hidesBottomBarWhenPushed {
return YES;
}
For example:
OrderViewController *controller = [[OrderViewController alloc] init];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
Or try to set property hidesBottomBarWhenPushed of self.tabBarController to YES.
Start with a UITabBarController project in Xcode, place a UINavigationController in each one of the tab view for the controller, and you're done! Hope that Helps!
I think hidesBottomBarWhenPushed is the way to go. There's some gotchas to keep in mind. Your setting this on the UIViewController that you're pushing, not on the tabBarController, or on the existing navigation controller.
Check here for more details: Setting hidesBottomBarWhenPushed leaves bottom bar missing after View Controller is popped
From that post, some sample code:
self.anotherViewController.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:self.anotherViewController animated:animated];
I have a toolbar with 4 UIBarButtonItem's, on click of one of the buttons, i would like to change the current view controller to another view controller.
Could please tell me how i could achieve this??
Thanks,
BR,
Suppi
Do you use UINavigationBar along with UIBarButtonItem?
If so, then just casual
[self.navigationController pushViewController:theViewCntrlrYouWant animated:NO];
should fit to your wish.
(Edited according to Suppi's observation)
If there's no navigation bar, then smth like:
YourViewController * first = [[YourViewController alloc] init];
[self presentModalViewController:first animated:NO];
[first release];
In my application the modal navigationcontroller that I am presenting is going under the current navigationcontroller so I'm not able to view the new navigationbar as it's disappearing under the current one.
I'm presenting the modalview on self and not self.navigationcontroller because self.navigationcontroller doesn't present the modalviewcontroller.
Also how to push a view on this modal navigationcontroller?
I'm using following code in one of my viewControllers:
fullListTopCompanies *fullListTopCompaniesInstance = [[fullListTopCompanies alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:fullListTopCompaniesInstance];
fullListTopCompaniesInstance.navigationController.navigationItem.title = #"F";
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[fullListTopCompaniesInstance release];
Can anybody please help?
Thanx in advance.
use animated with transition
according to me you have to change the animation style
i done it before but forgot the code i will post it when i get it
self.navigationController.navigationItem.title = #"F";
Add the above line of code in viewDidLoad method of "fullListTopCompanies" class.
Actually your navigation bar hides because of the modal view and modal view by default doesnt have Navigation bar.To add a navigation bar to modal view you can try the below code:
In Header File
IBOutlet fullListTopCompanies *fullListTopCompaniesInstance;
In Implementation File
UINavigationController *nav = [[UINavigationController alloc] initWithNibName:#"fullListTopCompanies" bundle:nil];
[self presentModalViewController:nav animated:YES];
[nav release];
Also on the "fullListTopCompanies" View Controller dont forget to put a left navigation bar button item for dismissing the modal view.
So add that left bar button (Ideally Cancel Button on navigation bar) and event handler for that left barr button should contain the code
[self dismissModalViewControllerAnimated:YES];
Hope this helps.
I am loading a Modal view controller using the following code in my RootViewController:
[self.navigationController presentModalViewController:accountViewController animated:YES];
In the accountViewController xib file, I have set a navigation bar. My MainWindow.xib and RootViewController.xib also have the navigation bar setup correctly. Additionally, my app delegate has setup the navigation controller (I assume) correctly:
UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navigationController = aNavigationController;
[window addSubview:navigationController.view];
However, when I load my accountViewController the UINavigationBar is nowhere to be seen. Is it not possible to show a UINavigationBar in a modal view? I was planning to use it to hide the back button, and add a right button...
sha's answer is correct, but I'm giving my own answer to expand on it with a code example to make it clear.
You probably want something like:
- (void)showAccountViewController
{
AccountViewController* accountViewController = [[AccountViewController alloc] initWithNibName:#"AccountView" bundle:nil];
...
// Initialize properties of accountViewController
...
UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:accountViewController];
[self.navigationController presentModalViewController:navController animated:YES];
[navController release];
[accountViewController release];
}
You need to push not viewController but navigationController that has viewController inside.
You can also set the presentation style in the Attribute Inspector to "Current Context". Modal View will not cover the Navigational Bar.
So, I'm having some issues with my implementation of the Three20 TTLauncherView. I am using their code, not a fork (although I have heard of rodmaz's version), and I can't get it to work properly. This is what my app looks like.
alt text http://img709.imageshack.us/img709/8792/screenshot20100715at409.png
I removed the icon image, that's not the issue. The issue is, at the top there is no Navigation bar at all, and I believe also causes the white strip at the bottom, which appears to have the same dimensions as a Nav Bar. I've spent quite a while looking through their code and can't figure this out at all. It looks like their Navigation bar (as seen in their Catalog example app) stems from the TTTableViewController, or something further up. However, my app starts like the Facebook app does, not into a table, but into the TTLauncherView. So... how do I get the Navigation bar into my TTLauncher view, if it goes "App Delegate -> TTLauncherView Subclass"
Thanks for your help!
Edit:
Added the code I used. I put this in my app delegate, wrapping my first view with the UINavigation Controller, and it worked just as I wanted!
MainViewController *aController = [[MainViewController alloc] initWithNibName:nil bundle:nil]; //my Main view
self.mainViewController = aController;
[aController release]; //release for Memory Management
self.mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
UINavigationController *navigationController = [[UINavigationController alloc] init];
[navigationController pushViewController:self.mainViewController animated:NO]; //Gets the main view on the screen
[window addSubview:navigationController.view];
You simply wrap the view with a navigation bar before you push the new view. As an example, here is a snippet of my code where I present a modal view controller with a navigation bar.
- (IBAction) showNewNavView: (id) sender
{
// Present it as a modal view and wrap the controller in a navigation controller to provide a navigation bar for the Edit and Save buttons
ModalViewController *addController = [[ModalViewController alloc] initWithNibName:#"ModalViewController" bundle:nil];
addController.delegate = self;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController];
navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[addController release];
}
If you want to add any buttons or set the title of it, you need to do that in the viewDidLoad method of the view that you are pushing (i.e. your TTLauncher view)