I've got two buttons on the right side of my UINavigationController that are working as expected. This is the code I'm using to make this happen:
I have a simple request: how do I disable a button in this array? For example say under a specific condition I wanted the Share button disabled, how would I go about doing this? Thanks in advance!
Code:
// Share Button
UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
[shareButton setFrame:CGRectMake(0,0,19,21)];
[shareButton addTarget:self action:@selector(shareButton) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *shareBarButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButton)] autorelease];
shareBarButton.tintColor = [UIColor whiteColor];
// Snapback Button
UIButton *navSnapbackButton = [UIButton buttonWithType:UIButtonTypeCustom];
[navSnapbackButton setFrame:CGRectMake(0,0,26,21)];
[navSnapbackButton setImage:[UIImage imageNamed:@"Snapback.png"] forState:UIControlStateNormal];
[navSnapbackButton addTarget:self action:@selector(snapbackButton) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *navSnapbackBarButton = [[[UIBarButtonItem alloc] initWithCustomView:navSnapbackButton] autorelease];
navSnapbackButton.tintColor = [UIColor whiteColor];
// Right Toolbar Button Setup
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:navSnapbackBarButton, shareBarButton, nil]];