I have a universal app and have an action sheet with a few buttons. When I tap the add button (navigationItem.right) I want it to show in a popoever. It does this correctly, however, with the actionSheet tied to the barbutton item, it allows me to continually tap the add button and have more popup.
I thought tapping outside the popover would dismiss this...
- (IBAction)ShowItemAdd:(id)sender
{
addActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:[dataObj.preferences objectForKey:@"appts_name"], @"Reserve", nil];
if ([[UIDevice currentDevice] isPad]) {
[addActionSheet showFromBarButtonItem:[[self navigationItem] rightBarButtonItem] animated:YES];
} else {
[addActionSheet showInView:self.view];
}
}
Why is this not auto dismissing if I have it bound to the barbutton item?
EDIT
Tapping anywhere in the navigationItem bar (blue bar) at the top will not close the actionSheet, however tapping outside of the nav controller, will dismiss the actionsheet.
In your method you should first check to see whether your actionsheet is already visible, and if it is, dismiss it instead of creating a new actionsheet.
- (IBAction)ShowItemAdd:(id)sender
{
if ([addActionSheet isVisible]) {
[addActionSheet dismissWithClickedButtonIndex:[addActionSheet cancelButtonIndex] animated:YES];
} else {
addActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:[dataObj.preferences objectForKey:@"appts_name"], @"Reserve", nil];
if ([[UIDevice currentDevice] isPad]) {
[addActionSheet showFromBarButtonItem:[[self navigationItem] rightBarButtonItem] animated:YES];
} else {
[addActionSheet showInView:self.view];
}
}
}