IOS Add Buttons to the Alert
Add Buttons to the Alert
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!" message:@"This is your first UIAlertview message." delegate:nil cancelButtonTitle:@"Button 1" otherButtonTitles:@"Button 2", @"Button 3", nil];[message show];
Respond to Alert Button Selection
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSString *title = [alertView buttonTitleAtIndex:buttonIndex]; if([title isEqualToString:@"Button 1"]) { NSLog(@"Button 1 was selected."); } else if([title isEqualToString:@"Button 2"]) { NSLog(@"Button 2 was selected."); } else if([title isEqualToString:@"Button 3"]) { NSLog(@"Button 3 was selected."); }}
Comments
Post a Comment