I have used the following code for years to add a right bar button item to the navigation bar, but for some unknown reason, this no longer works. It stopped working when I updated my app to have Scene support. I don't understand what is preventing this code from working.
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"viewDidLoad");
// Add a Share Button
UIBarButtonItem *shareButton;
shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(editProject:)];
self.navigationItem.rightBarButtonItem = shareButton;
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blueColor];
}
-(void) editProject:(id)sender {
}
@end
To test this, I created a brand new test app that does nothing except for attempting to add this button. The autogenerated code gives you the following project and I simply modified the ViewController class as shown above:
What do I need to do differently to make the right bar button item to display? I know that I can add buttons using the storyboard that can be controlled via IBOutlets, but just want to know if its still possible to do this programmatically.