How can i add a navigation bar to presentModalViewController programmatically?

Mumthezir VP picture Mumthezir VP · Feb 13, 2013 · Viewed 10.6k times · Source

How can i add a navigation bar to presentModalViewController programmatically? I know default navigation bar will be there in pushViewController.. hope your help...

Answer

Vinayak Kini picture Vinayak Kini · Feb 13, 2013

Make use of this code in viewDidLoad.

UINavigationBar *myBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
[self.view addSubview:myBar];

This will add navigation bar to your view.