UIAlertView delegat "didDismissWithButtonIndex" get wywoływana za każdym razem u kliknąć dowolny przycisk.
Spróbuj tego:
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];
}
}
Jej nie dong nic po kliknięciu któregokolwiek z tych przycisków. – Ashutosh
znajdź zaktualizowany kod – iPhoneDev
Prawidłowa odpowiedź. Wskazówka: nie mylić 'didDismissWithButtonIndex' (wywołanego * po * UIAlertView opuszcza hierarchię ekranu) z' clickedButtonAtIndex' (wywoływanym, gdy UIAlertView jest nadal na ekranie i nadal stanowi część hierarchii widoku ekranu). Znalazłem to pomylenie w innych odpowiedziach StackOverflow i innych miejscach w Internecie. –