- (void)viewDidLoad
{
[super viewDidLoad];
ac = [[AddContacts alloc]init];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:ac];
[self.view addSubview:navigationController.view];
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Show" style:UIBarButtonItemStylePlain target:self action:@selector(refreshPropertyList:)];
self.navigationController.navigationItem.rightBarButtonItem = anotherButton;
}
Why is my button not being added on the navigation controller?
The
UIBarButtonItems are not controlled by the navigation controller, but by each of the view controllers it contains – eachUIViewControllercan have different buttons. Try:Then initialize the
UINavigationControlleras you have been doing.