mercredi 28 décembre 2016

add checkbox in UIAlertController

I need to add a check box in the alert asking if I should show this message again. I came across various examples where a button or a text field was added in the controller but didn't see a checkbox anywhere. UIAlertView is deprecated above version 9 so I don't want to use that.

UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil message:@"Should I remind?" preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  [self goToAddReminderView];
}];
UIAlertAction *noAction = [UIAlertAction actionWithTitle:@"NO" style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) {
[self.navigationController popViewControllerAnimated:YES];
}];

[alert addAction:yesAction];
[alert addAction:noAction];

[self presentViewController:alert animated:YES completion:nil];

I would appraciate an example.




Aucun commentaire:

Enregistrer un commentaire