otherButtonTitles в UIAlertView - PullRequest
       2

otherButtonTitles в UIAlertView

9 голосов
/ 23 июля 2010

Мне просто было любопытно, как я могу прикрепить какую-то другую задачу к другому кнопке заголовка UIAlertView.Кнопка отмены автоматически выводит вас из приложения, но если я хочу прикрепить другую задачу с помощью otherButtonTitle, что мне делать?

Спасибо,

1 Ответ

22 голосов
/ 23 июля 2010

UIAlertView делегат "didDismissWithButtonIndex" вызывается каждый раз, когда вы нажимаете любую кнопку.

Попробуйте это:

UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Message" 
                                                message:messageString
                                               delegate:self 
                                      cancelButtonTitle:@"Back"
                                      otherButtonTitles:@"Reply",@"Delete",nil];
[alert show];
[alert release];


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex 
{
  if (buttonIndex == 1)
  {
    NSLog(@"Reply");
    UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"Button Clicked" message:@"U clicked Reply " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [myalert show];
    [myalert release];  
  }

  if (buttonIndex == 2)
  {
    NSLog(@"Delete");
    UIAlertView *myalert = [[UIAlertView alloc] initWithTitle:@"Button Clicked" message:@"U clicked Delete " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [myalert show];
    [myalert release];  
  }
}
...