Alert do different Actions in your Xcode IOS project
How to make Alert do different Actions in your Xcode IOS project
This is all the code you need to make an Alert show up when you press a button and then it will do an action based on which
option the user clicked:
- (IBAction)NameOfButton:(id)sender {UIAlertView *alert =
[[UIAlertView alloc] initWithTitle:@"What do you want to do?" message:@"Are you sure?" delegate:self
cancelButtonTitle:@"Yes, Do This" otherButtonTitles:@"No, do this instead", nil]; [alert show];}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
// Yes, Do This actions
}
if (buttonIndex == 1) {
// No, do this instead
}
}
|
|
|
|
|