How do I determine if the cancel button was pressed on a UIActionSheet?
My UIActionSheet is set up like this:
-(IBAction)fileButtonPressed
{
UIActionSheet *mymenu = [[UIActionSheet alloc]
initWithTitle:@"Select Folder"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:nil];
for (i=0; i<3; i++)
{
[mymenu addButtonWithTitle:@"Button Name"];
}
[mymenu showInView:self.view];
}
The problem that I have is that I cannot differentiate between the cancel button and the first button selected.
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *option = [actionSheet buttonTitleAtIndex:buttonIndex];
//buttonIndex == 0 if the cancel button is pressed or
//if the first item is pressed.
}
Is there a better way of setting this up?