You would need to adjust on orientation change.
I have found an alternative solution, that works perfectly for me.
Stick to
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
In your @interface add
UIActionSheet *popoverActionsheet;
also add
@property (nonatomic, retain) UIActionSheet *popoverActionsheet;
also add
- (IBAction)barButtonItemAction:(id)sender;
So you have reference to your actionsheet from anywhere in your implementation.
in your implementation
- (IBAction) barButtonItemAction:(id)sender
{
//If the actionsheet is visible it is dismissed, if it not visible a new one is created.
if ([popoverActionsheet isVisible]) {
[popoverActionsheet dismissWithClickedButtonIndex:[popoverActionsheet cancelButtonIndex] animated:YES];
return;
}
popoverActionsheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:@"Save Page", @"View in Safari", nil];
[popoverActionsheet showFromBarButtonItem:sender animated:YES];
}
in your actionsheet delegate implement
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == [actionSheet cancelButtonIndex]) return;
//add rest of the code for other button indeces
}
and don't forget to release popoverActionsheet in
- (void)dealloc
I trust that this will do.