Skip to content

Instantly share code, notes, and snippets.

@iggym
Created May 9, 2013 22:30
Show Gist options
  • Save iggym/5551104 to your computer and use it in GitHub Desktop.
Save iggym/5551104 to your computer and use it in GitHub Desktop.
UIAlertView basics
//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