L'esempio seguente da un'idea di come è possibile farlo tramite Xcode (ma leggere più avanti il link che avverte del metodo deprecato in alcune versioni di iOS).
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"TITOLO DI ESEMPIO"
message:@"MESSAGGIO DI ESEMPIO"
delegate:self
cancelButtonTitle:nil // cancelButtonTitle:@"CANC"
otherButtonTitles:@"OK", nil];
alert.tag=101;
[alert show];
//per ricevere l'evento del pulsante cliccato
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
//...other code
}
//...
}
N.B. "Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert." riferimento qui Developer Apple