Add cancel and other button to the existing UiAlert/Alertdialog (iOS & Android)

mat0pad

  • Posts: 364
To the built in block (see attachment) why not add the possibility to make two or more buttons. This is a pretty standard thing. Fx if you have a reset button in your game you show an alert with two buttons as a built in safe. Or if you prompt a user with a rate request box they would have the option to select no/maybe later or yes. Or even if you have an in-game shop you can prompt the user when trying to buy an item "are you sure you want to buy this".

For the iOS side this would be something like:
Code: [Select]
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Rate me please!"
                                                        message:@"rate!"
                                                       delegate:self
                                              cancelButtonTitle:@"NO"
                                              otherButtonTitles:@"Yes", nil];

    [alertView show];
    [alertView release];

But for this to work well we woud also need a method to catch what's pressed.
This would probably be something like:
Code: [Select]
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  {
          if(buttonIndex == 0)//No button pressed
          {

          }
          else if(buttonIndex == 1)//Yes button pressed.
          {

          }
  }

I would like to see this added in the furture for both Android and iOS.