Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Prompt to UINavigationBar Programmatically

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

like image 733
Justin Bush Avatar asked Mar 16 '13 23:03

Justin Bush


2 Answers

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;
like image 62
Aaron Golden Avatar answered Nov 15 '22 19:11

Aaron Golden


Proper way is

self.navigationItem.prompt = @"Hello";
like image 28
Saqib Saud Avatar answered Nov 15 '22 19:11

Saqib Saud