8

How do I programmatically make my UINavigationBar (which doesn't have a UINavigationController) have a prompt whom's text value equals webTitle.

I've tried the following with no luck:

self.navigationItem.prompt = webTitle;

The only way I have been able to create a prompt is by applying the following settings onto the NavigationBar in IB.

Yeah

2 Answers 2

15

I'm assuming your UINavigationBar belongs to whatever has the webTitle variable. Let's say the UINavigationBar exists as a property called navigationBar, then you can use this

self.navigationBar.topItem.prompt = webTitle;
2
  • 2
    This answer should be accepted. The other one is a hack, imo.
    – katzenhut
    Nov 17, 2013 at 16:29
  • 2
    Also if you have a uinaviagioncontroller, it would just be self.navigationItem.prompt = webTitle
    – Lucas
    Jun 1, 2014 at 23:47
10

Proper way is

self.navigationItem.prompt = @"Hello";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.