lunedì 7 settembre 2015

Creare un semplice messaggio in app per iOS

Come inviare un messaggio a video in un'applicazione per iOS/Iphone?
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