what's the proper way to add a UIBarButtonItem programmatically? In my case I'm trying to add one to the rightBarButtonItem
and I've been hopping round the controller hierarchy but I can't seem to get the button to show up anywhere.
Here's my current code:
- (void)viewDidLoad {
[super viewDidLoad];
[self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[[UIImage alloc] initWithContentsOfFile:@"Barcode-White.png"] style:UIBarButtonItemStylePlain target:self action:@selector(scanEquipment:)] autorelease]];
}
I'm hoping someone can guide me into the right direction. The controller I'm trying to invoke this from is 3 levels in. So, UITabBarController
-> UIViewController (Settings, 1st level)
-> UIViewController (Vehicle, 2nd level)
-> UIViewController (Inventory, 3rd level)
.
Anyway, thanks in advance for any help!