How to add image and text together in iPhone Navigation bar - iphone

How can I add image and text together in an iPhone Navigation bar?

From a view controller, you can ask for self.navigationController.navigationBar and add subviews to that.
Or, you can wrap image/text into a UIView, and create a UIBarButtonItem with a custom view set to that combination.

For my answer, I'm assuming you want to show an image in the NavBar with the text prompt above it - in which case, you'd be looking to use the prompt property on the UINavigationItem class.

Related

How to Add Custom UIPickerView to UINavigationBar?

I need to add custom picker view toUINavigationBar like this. But If I move pickerview to UINavigationBar it appears behind UINavigationBar.How can I display it correctly above the UINavigationBar?
you can add like this,
[self.navigationController.navigationBar.topItem setTitleView:pickerView];
Hope it will helps you.....
You would have to add a custom UIView which contains the UIPickerView and add it programmatically as the center view inside the UINavigation Controller. It should load the picker instead of the title for that page.
You should create a custom view having blue background. Add appropriate views into it.
Hide the navigation bar for this screen.

UIView on top of navigation item

I have a view controller that's embedded in a navigation controller. Therefore this view controller has a navigation item at the top. One of the things you can do in ios6 storyboards is that you can set the title, prompt and back button for this view controller (because its embedded in a navigation controller).
That being said, when I specify a title and test the app, everything looks good. However, when I place a transparent UIView on top of the navigation item (such as where the title is), the title itself just vanishes. The text itself that I typed into interface builder is gone. I have proven this because if I delete the view I created, the text I initially had is gone.
I tried to mediate the problem by actually setting the title itself outside of the interface builder:
self.navigationItem.title=#"My Title";
But that doens't seem to work either. Does anyone have a clue as to how I can hide/show a transparent UIView on top of a navigationItem in a navigation controller?
EDIT
Any UI element I place in the navigation controller toolbar seems to prevent the underlying title text from showing up. This happens even if the element is marked as transparent AND its set to hidden.
My understanding is that Interface Builder is, more or less, mimicking what you would do if you did the same thing programmatically using the UIBarButtonItem class. The various items in a navigation bar are instances of the UIBarButtonItem class. This class has the following initializers:
– initWithBarButtonSystemItem:target:action:
– initWithCustomView:
– initWithImage:style:target:action:
– initWithTitle:style:target:action:
– initWithImage:landscapeImagePhone:style:target:action:
When you just have a title for the navigation controller, Interface Builder treats it similar to using the initWithTitle: initializer. Basically, this means that, under the hood, a UILabel class is created with the given title and that UILabel is used as the view for the UIBarButtonItem.
When you are dragging the transparent view over the title, however, Interface Builder is instead doing the equivalent of calling initWithCustomView:. This means that the view you are providing is being used as the UIBarButtonItem's view. In other words, when you drag the custom view over the title, you are not placing it on top of the title. You are replacing the title with the transparent view.
One option might be to create a view which has both a UILabel and the transparent view as subviews. Then place that view as the title for the navigation bar. If you give that UILabel the correct font size and shadow, it will look indistinguishable from the system's default title and you will also be able to have the transparent view on top of it.
In IB, you can drag a UIView to the center of the navigation bar, and this will replace the titleView that is there by default (you can do it in code with setTitleView:). If you make its background clear and add a label to it to hold the title, it will look like the default title. You can then add another UIView as the subview of this view, just like you would with any other UIView.

How do I set the Navigation Bar Title as a editable text field?

I would like the user to be able to edit the title of the navigation bar. I feel like I've seen it in an app before. Is this possible?
If you are using a UINavigationController then play around with
self.navigationItem.titleView = // UITextView
You will have to customize your navigationBar and add the UITextField as as subView, and place it accordingly.

iPhone Dev - Is it possible to remove a button from a UINavigationController's navigationBar?

When I push a view via my app's navigationController, it automatically puts a back button on the left side of the navigationBar. Is there any way I can just remove this? (I want to put my own buttons on the screen that will allow the view to be popped).
From the comments, you can hide the back button for a viewController by using its navigationItem property. (which is the UINavigationItem corresponding to that viewController in the stack of the navigationController. its how you control what shows up on the bar for specific view controllers (see Apple Doc here)).
To answer your question, set the navigationItem's hidesBackButton property to YES. Something like this probably called in your viewControllers viewDidLoad: or similar method.
myViewController.navigationItem.hidesBackButton = YES;
have you try with self.navigationItem.hidesBackButton=YES;?
If I wanted to do it, I'd hide the Navigation bar on push (non animated hide), add a toolbar, and add any custom stuff I want to the toolbar.
on popping the view controller, make sure to unhide the navigation bar. It'll work

UiBarButtonItem without toolbar or navbar

I like the look of the UIBarButtonItem buttons. Is there a way to put these on a screen without using a UINavigationBar or UIToolbar.. so the button are just placed straight onto a view? (or possibly put them onto on nav bar or toolbar whose content is invisible, except for the bar buttons)
As they do not inherit from UIView and don't expose a view property (except for those customView based ones), you cannot simply add them onto views out of the box. Also, they might need to "talk back" to their bar container, which would fail anyway. Go with UIButton with custom image.
You cant use Bar button directly on button if you like those button then you can pick the image for same and use that with the round rect or custom button.