I have a method called -showMoreTools: which is:
- (IBAction) showMoreTools:(id)sender {
UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:@"Close" otherButtonTitles:@"Add Bookmark", @"Add to Home Screen", @"Print", @"Share", nil];
popupQuery.actionSheetStyle = UIActionSheetStyleDefault;
popupQuery.dismiss
[popupQuery showFromBarButtonItem:moreTools animated:YES];
[popupQuery release];
}
When an user taps a UIBarButtonItem
it displays that UIActionSheet
, but then, if the user wants to close the UIActionSheet
without taping the Close button, (taping the UIBarButtonItem
, then it displays the UIActionSheet
over the first UIActionSheet
.
It's possible to implement somehow taping another time the UIBarButtonItem
to close the UIActionSheet
?
Thank you so much – I'm a newbie in iOS Programming!
use
try by setting the flag(YES/NO)
My method is similar to christophercotton's.
In my showActionSheet I check if the actionsheet is visible rather than instantiated:
I found another solution to this. The problem is that when using
showFromBarButtonItem
, the toolbar view is automatically added to the popover's list of passthrough views. You can modify (and clear) the passthrough views when using aUIPopoverController
directly, but not when it's presented as part of aUIActionSheet
.Anyway, by using
showFromRect
, there is no toolbar that the popover can automatically add to its passthrough views. So if you know the (approximate) rectangle where your button bar is, you can use something like:In the above example, my button is on the left hand side of the toolbar.
In order to dismiss it when you click on the button twice, you need to keep track of the currently displaying ActionSheet. We do this in our iPad app and it works great.
In your class that has the showMoreTools, in the header put:
In the class file, change it to: