Search code examples
iosuitableviewpresentmodalviewcontroller

How can i add a navigation bar to presentModalViewController programmatically?


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


Solution

  • 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.