Created
May 9, 2013 22:30
-
-
Save iggym/5551104 to your computer and use it in GitHub Desktop.
UIAlertView basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//basic alert view , remember <UIAlertViewDelegate> | |
- (IBAction)showMessage:(id)sender { | |
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!" | |
message:@"This is your UIAlertview message." | |
delegate:nil | |
cancelButtonTitle:@"OK" | |
otherButtonTitles:nil]; | |
[message show]; | |
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex | |
{ | |
} | |
//UIAlertView with buttons | |
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!" | |
message:@"This is yourUIAlertview message." | |
delegate:nil | |
cancelButtonTitle:@"Button 1" | |
otherButtonTitles:@"Button 2", @"Button 3", nil]; | |
[message show]; | |
} | |
- (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."); | |
} | |
} | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment