How to Name navigation bar [duplicate] - iphone

This question already has answers here:
iPhone: Setting Navigation Bar Title
(13 answers)
Setting title of UINavigationBar
(3 answers)
Closed 10 years ago.
in my app i'm am basically pushing a viewcontroller from another one
[self.navigationController pushViewController:vc animated:YES];
The view controller that results from this call has a navigation bar but I can't name it through the story board. Basically, how do I set the navigation bar's text in code?

add this line to viewDidLoad
self.navigationItem.title = #"MyTitle";

If you are working in the storyboard then you can also set the title of the navigationBar just double clicking on the navigationBar. I will work fine for you. try that.

Related

TabBars and iOS 7

I have a UITabbarController that I'm pushing another controller on top of using a UINavigationController. On iOS 6 and below, the tabBar of the parent controller slides away and the toolbar of the new view controller is presented. But on iOS 7 the tabBar doesn't animate away even if I run the code [self.navigationController setToolbarHidden:YES animated:NO];
EDIT - Okay I narrowed my problem to iOS 7 not respecting the hidesBottomBarWhenPushed property, I followed the answers in hidesBottomBarWhenPushed ignored in iOS 7 but it didn't work. The view that is pushed has a toolbar with buttons and the buttons are responding to touches, it's just that the tabBar is on top of the toolbar.
in iOS7 you need to set the property hidesBottomBarWhenPushed to YES on the presented controller instead of the presenter controller to hides the tabbar.
Turns out there was an view not being removed on my custom TabBar.

Mail Compose View Controller Navigation Bar [duplicate]

This question already has answers here:
Override UIAppearance property for MFMailComposeViewController
(3 answers)
Closed 9 years ago.
I am setting the appearance protocol to add a custom image for all my navigation bars. This is working as expected, but I do not want to change the appearance for the
MFMailComposeViewController's navigation bar.
How can I make this navigation bar, the default navigation bar?
[[UINavigationBar appearance] setBackgroundImage:[ApplicationStyle navigationBarImage] forBarMetrics:UIBarMetricsDefault];
The appearance proxy enables you to modify the appearance of the UI when it's contained in a specific class through the -appearanceWhenContainedIn method. You can set the image to nil to prevent it from being shown in the MFMailComposeViewController class as shown below.
[[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
According to this question, you need to change the appearance proxy before and after you present the modal MFMailComposeViewController in order to change its appearance back to how it was.
Override UIAppearance property for MFMailComposeViewController

iPhone SDK have a different title on the tab bar and the navigation bar

I have a simple question (maybe not a simple answer). Currently I have an iPhone app and I tab bar and navigation set up on it. When I set the self.title it puts it in both the tab bar and the navigation bar. I was wondering if there was a way to have a different title on the navigation bar and tab bar?
You're setting the title of the whole view, which in turn automatically sets the title of the tabBar and the nav controller. To set the title of them each individually,
You first set the nav bar by accessing the nav item:
[[self navigationItem] setTitle:(NSString *)];
Then you set the tabBar title by accessing the tab bar item and setting its title like so:
[self.tabBarItem setTitle:(NSString *)];
Good Luck!
use self.navigationItem.title for the navigation bar.
This is a common mistake and happened to me so many times.
To get around this, every ViewController comes with a navigationItem property giving you even further options.
Use following line inside your ViewControllers to set the title:
self.navigationItem.title = #"Your Desired Title";

How to change the view if I am not present in the viewController class? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Code is exectuting but the view is not loading when called form a function?
I am doing an app with about 6-7 views and their corresponding controllers. I am in a view with a toolbar and button.
When I click this button a popup view comes and my control is being moved to the popup view's Controller. But my view is still the same.
From this popupview Controller's class, I want to change my original view. But since I am not in my original viewControllers class, I am not able to change it.
How can I overcome this? Can anyone plz help me?
If you're adding the Popup View as a Subview of the Original ViewController's View, you can access the parent view using superview.
UIView *parentView = popupViewController.view.superview;
then you can change the parentView as needed.

How to set the text of a back button on a UINavigationBar? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I change the title of the “back” button on a Navigation Bar
The Situation:
I have a UIViewController that is governed by a navigation controller. I am able to set the title of the navigation bar covering the UIViewController by simply calling self.title = #"title". But, I want to be able to set the back button text of the navigation bar, too (for different languages n' such..)
The Problem:
I don't know how to set the back button's text.
The Question:
How do I set the back button of the UINavigation bar (programmatically not in IB)?
The setTitle way - though may seem to work, is incorrect. If you pay attention closely, you will notice that the navigation item changes to the new title while the new view is animated into view via pushViewController. The fact that you have to restore your title in viewWillAppear is kludgy, which further suggests its hack nature.
The correct way is to do the following before your pushViewController:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
initWithTitle: #"Back Button Text"
style: UIBarButtonItemStyleBordered
target: nil action: nil];
[self.navigationItem setBackBarButtonItem: backButton];
[backButton release];
The best and easiest way according to apple documentation to set the view controller's title to what the back should say is this -
Example:
If viewController1 is under viewController2 (and the back button on viewController2 is going to viewController1)
viewController1.title = #"something awesome";
the back button on viewController2 will show "something awesome"